How can I create a list of reserved words in a Ruby program? [closed]

偶尔善良 提交于 2019-12-25 03:48:25

问题


I know that I can just browse the web for these words but is there a way to just let Ruby do it for me? You don't have to give me a whole program, just some hints to let me go about it. Thanks in advance.


回答1:


Well, you can always take a look at the ruby's source code: keywords.




回答2:


You can't get Ruby to do this for you.

However, here's the list from Dave Thomas's Programming Ruby 1.9, The Pragmatic Programmers' Guide (Also known as the Pickaxe):

__FILE__, __LINE__, BEGIN, END, alias, and, begin, break, case, class, def, defined?, do, else, elsif, end, ensure, false, for, if, in module, next, nil, not, or, redo, rescue, retry, return, self, super, then, true, undef, unless, until, when, while, yield



来源:https://stackoverflow.com/questions/14885418/how-can-i-create-a-list-of-reserved-words-in-a-ruby-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!