From: Eric Hodel Date: 2005-09-14T03:38:36+09:00 Subject: Re: BEGIN and END vs. blocks On 13 Sep 2005, at 04:26, leonardo.pires@gmail.com wrote: > I forgot to say what I want to know in my first email (sorry!) and > noticed this only now: why I can't use the do form with BEGIN or END? > > END do > puts 'wow' > end > > It's invalid! Because there's something implicit? It is required to use { }, from parse.y: | klBEGIN { if (in_def || in_single) { yyerror("BEGIN in method"); } local_push(0); } '{' compstmt '}' { ruby_eval_tree_begin = block_append (ruby_eval_tree_begin, NEW_PREEXE($4)); local_pop(); $$ = 0; } | klEND '{' compstmt '}' { if (in_def || in_single) { rb_warn("END in method; use at_exit"); } $$ = NEW_ITER(0, NEW_POSTEXE(), $3); } -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04