2 ms·
great! wonder why most people don't use it? I keep seeing "end" in almost every chunk of Ruby code I see on the web.
by mkramlich 16y ago
great! wonder why most people don't use it? I keep seeing "end" in almost every chunk of Ruby code I see on the web.
- steveklabnik 16y agoThe general convention is that {} is for one line blocks, and do/end for multiline. [1,2,3].each{|n| puts n } versus [1,2,3].each do |n| m = n + 1 puts m end The reason? do/end is much prettier than {}, but {} is really nice for chaining... [1,3,2].collect{|n| n + 2 }.sort
- ShardPhoenix 16y agoI find it easier to type "end" than "}".
- mkramlich 16y agobut it's 3 characters versus 1. is it easier because you don't have to hit SHIFT?