From: "C. Dagnon" Date: 2009-03-05T01:02:36+09:00 Subject: Any solutions to Ruby's inconsistencies? Ruby has definite positives over Java and even other scripting languages, but many negatives too. One negative is the inconsistency of how rules seem to be applied in the language and accompanying toolsets. Here are a few that have bitten me: 1. I almost immediately got started with Ruby on Rails and loved the idea of partials, but then I found that the ||= idiom doesn't work on partials' parameters. <% my_param_a ||= 1 # Errors out my_param_a = my_param_a ? my_param_a : 1 # works -%> That seemed odd as I thought both were equivalent, and it broke some of the trust I had for Ruby. Not as much as early Rails' use of 2 separate variables for RAILS_ENV, but... 2. Then when using blocks to process an array I tried to use another Ruby control structure: arr=[1,2,3,4] arr2 = arr.collect{|ii| return 0 if ii == 3; ii+1} # result: LocalJumpError: unexpected return That also caught me off guard - I need the block to return a value, to evaluate to a value - but suddenly I'm told that 'return' doesn't mean what I think it means? At least not inside a block (or Proc.new)... 3. Originally I was taught that symbols were the salvation of memory and key problems - and they certainly sounded like it. Up until the point a few days later when one (Rails?) map used Symbols and another used Strings. Ouch. Without any explicit typing abilities in the language (optional or otherwise?) it seems like the only solution is to return to basic string matches: regex = Regexp.compile("^#{matcher.to_s}$", Regexp::IGNORECASE) key = map.keys.find{ |key| key.to_s =~ regex } Yuck. 4. And what's up with Ruby incorrectly naming their Map 'Hash'? Or is my C.S. idea of a Hash too limited? Granted in Java they have HashMap, but if you enter one value and get a second one out it is a Map, regardless of how the keys are stored. A 'Hash' would instead be a type of set. Please let me know how I can supplement my possibly deficient Ruby education :) Relevant discussions or sections of "The Ruby Way" appreciated! -Chris -- Posted via http://www.ruby-forum.com/.