From: Robert Klemme Date: 2006-04-29T03:42:31+09:00 Subject: Re: how to use curly brackets vs. 'end' in Ruby 2006/4/28, carlo : > i dislike the use of 'end' (just about the only think i *don't* like in > ruby). so, since everybody is saying that this is just a matter of > taste, why won't this work: > > class Hello > { > attr_reader :msg > def initialize > { > @msg = "Hello, World" > } > } > h = Hello.new > puts h.msg > print "Press RETURN" > $stdin.gets Because it's syntactically not permitted. Note that {...} can only replace do...end. > Or what about this: same. > in other words, i'm more comfortable with {} coming from C,C++, & C# so > what are the precise syntax rules for substituting {} for 'end'? is > there anything wrong with how i structured my code above? I keep getting > syntax errors & "odd number list for Hash" errors, & i'm pretty sure it > has something to do with my syntax, since both of these work in their > original form (using 'end'). obviously, ruby thinks i'm trying to create > a hash. so, how can i use {} instead of 'end' w/o confusing ruby? http://ruby-doc.org/docs/ProgrammingRuby/html/intro.html#S6 Kind regards robert -- Have a look: http://www.flickr.com/photos/fussel-foto/