From: Benoit Daloze Date: 2010-08-07T20:07:04+09:00 Subject: Re: Adding sugar to Ruby Hi, On 6 August 2010 21:41, Jan Lelis wrote: > Hi, I've collected some nice little additions to Ruby and put them in a > gem called zucker. > > Some of the features: > > * control structure like iteration: > > iterate [1,2], [3,4,5] do |e,f| >  puts "#{e},#{f}" > end > # outputs > #  1,3 > #  2,4 > #  ,5 [3,4,5].zip([1,2]).each { |e,f| puts "#{f},#{e}" } would do the same (the reverse order is needed to get the extra value). It is definitely better looking than something like Vector#each2, though. > * Regexp.union shortcut > > /Ruby\d/ | /test/i | "cheat" > # creates a Regexp similar to: > #  /(Ruby\d|[tT][eE][sS][tT]|cheat)/ Looks like syntactic sugar. I would need a real use-case to see if it is really better. You can already do something like this: case str when /Ruby\d/, /test/i, "cheat" end > * Blocks, where nil can be egocentric > > egonil do >  nil.some_methods.that[:do].not.exist > end # => nil > > * Array#to_proc > > [1,2,3].map &[:*, 5]  # => [5, 10, 15] That is rather cool ! I extended a bit the concept to allow multiple syntax: http://github.com/eregon/Classes/blob/master/to_proc.rb I would not use any of these for serious code, however. > * More at http://rubyzucker.info / http://github.com/janlelis/zucker > > What's your opinion about these methods? > > J-_-L > Some nice hacks and ideas. I guess some real examples would help to see the utility of it.