From: Zsban Ambrus Date: 2004-05-05T22:29:04+09:00 Subject: Empty set of parens, as expression It seemed to me that in ruby an empty set of parens just means nil. For example n=1;n=();p([(),5,2,n,(),7]) prints [nil, 5, 2, nil, nil, 7] However, when I write them as the last statement in a method or a begin (with or without a semicolon after it, it seems to do nothing. For example def set; a= 2; (); end; puts set(); prints 2. It seems that (()) and ((())) work the same way as (). (As an expression I mean, not in 'p()' and 'p(())' which are of course different.) (All examples are with ruby 1.8.1 (2003-12-25) [i686-linux]) I think that this behaviour might stem from that you can use a parenthisized list of commands (separated with semicolons) as an expression just like a begin-end block. (This is a Good Thing^{TM} IMO.) Thus, '()' is just an empty block. However, if this is the case I don't understand why its return value is ignored at the end of a block: p((2; ();)) prints 2, but p((2; begin end;)) prints nil. (Again, the semicolon after '()' or 'begin end' changes nothing. Is this difference between () and begin...end intended or accidental, and might it change in the future? Thanks for any comments, ambrus