问题
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