From: Jules Jacobs Date: 2006-01-30T02:05:38+09:00 Subject: Syntax Hi, Which syntax do you like most? 1. if ----- # block-by-indentation if a == 10 print a # Java/C, etc style if(a == 10) { print(a); } # Ruby style if a == 10 print a end 2. Rails' link_to ----------------- link_to 'Show', :action => :show, :id => @post link_to 'Show', action: 'show', id: @post link_to 'Show', action: :show, id: @post link 'Show', to: {action: 'show', id: @post} 3. Classes ---------- # Ruby class Foo def method print 'hi' end end # Indentation class Foo def method print 'hi' 4. Loop ------- 5.times i print i 5.times do |i| print i end for 0, 5, i print i end 5. Map ------ arr = [1, 2, 3] arr.map{|e| e * 2} arr.map do |e| e * 2 end arr.map(e, e * 2) arr.map(e * 2) # variable is 'e' (element) by default or maybe: arr = new Array(); arr.add(1); arr.add(2); arr.add(3); for(i = 0; i < arr.length(); i++) { arr[i] = arr[i] * 2; } ;-) -------------- I am trying to imagine the 'perfect' scripting language (for me, at least ;-)). Ruby is close, but I prefer a different syntax in some cases. I find the indentation-based code-blocks nicer than do...end-blocks. I also prefer this: arr.map(e, e * 2) or: # parentheses are optional arr.map e, e * 2 to this: arr.map{|e| e * 2} I'm not sure whether or not default variable names like this: arr.map(e * 2) are a good thing... What do YOU like, and why? Thanks in advance, Jules -- Posted via http://www.ruby-forum.com/.