Closed telemachus closed 9 years ago
you are using BEGIN in function body. and error says it can be used out of function body. BEGIN can only be used at file scope.
@kaleemullah360 I'm not sure I follow what you're saying. My point was that in different versions of Ruby the rules for BEGIN
are different.
in older version of ruby it doesn't show such error now it does in ruby > v2
and also tested this problem. when I put BEGIN
inside function body it throws exception and when I put it out of function body it works fine.
http://whitequark.org/blog/2013/04/14/unmentioned-features-of-ruby-2-dot-0/
in older version of ruby it doesn't show such error now it does in ruby > v2
Yes. I know. That's what I was saying. I wasn't asking about the differences, and I wasn't confused why there was an error.
I just thought this guide should mention the variation in how BEGIN
and END
work for different versions of Ruby. But it no longer matters since this guide is gone (the whole website is gone).
Thanks.
It might be worth documenting how
BEGIN
/END
outside of the top level of code works (or doesn't work) in different Rubies: