RoR-3.0.1

I have this case statement:

  case n.hll_normalize
    when "common name"
      @my_correspondent.correspondent_common_name = s
    when "legal name"
      .  .  .
    else
      raise ArgumentError, "#{n} attribute is not provided for."
  end

hll_normalize is defined as:

  def hll_normalise
    strip.squeeze(" ").mb_chars.downcase
  end

I pass this case statement this value for n: "common name"

When run with Ruby-1.8.7p302 this works.  The exact same code run with
Ruby-1.9.2p0 yields:

common name attribute is not provided for. (ArgumentError)

When I enter rails console then I see this:

$ rails c
Loading development environment (Rails 3.0.1)
ruby-1.9.2-p0 > x = "common name"
 => "common name"
ruby-1.9.2-p0 > x.mb_chars
 => common name
ruby-1.9.2-p0 > x.mb_chars.downcase
 => common name
ruby-1.9.2-p0 > "common name" == x.mb_chars.downcase
 => true
ruby-1.9.2-p0 > "common name" == x.strip.squeeze(" ").mb_chars.downcase
 => true
ruby-1.9.2-p0 > case x.strip.squeeze(" ").mb_chars.downcase
ruby-1.9.2-p0 ?>  when "uncommon" then puts "nothing"
ruby-1.9.2-p0 ?>  when "common name" then puts x
ruby-1.9.2-p0 ?>  end
 => nil
ruby-1.9.2-p0 >

So, what is the case statement sensitive wrt mb_chars that changes the
result of "common name" == x.strip.squeeze(" ").mb_chars.downcase when
used as an argument?  Is there a nil coming back from somewhere in the
case statement argument evaluation when mb_chars is involved?

This is definitely related to mb_chars because this works:

ruby-1.9.2-p0 > case x.strip.squeeze(" ").downcase
ruby-1.9.2-p0 ?>  when "uncommon" then puts "nothing"
ruby-1.9.2-p0 ?>  when "common name" then puts x
ruby-1.9.2-p0 ?>  end
common name
 => nil
ruby-1.9.2-p0 >

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to