On 6/20/05, Florian Gro<florgro / gmail.com> wrote:
> Jason Foreman wrote:
> 
> > If you accidentally write x = 1 instead of x == 1, it can take a long
> > time to figure out your bug.
> 
> C:\Dokumente und Einstellungen\flgr>ruby
> foo = 10
> if foo = 10 then
>    puts "Hello World!"
> end
> -:2: warning: found = in conditional, should be ==
> ^Z
> Hello World!
> 
> I found out about my bug before I was even done giving Ruby the full
> application code. ;)
> 
> 
> 

Nice.  I didn't realize it gave that warning!  :)

However:

$ ruby
x=2
case x
  when x=1:  p 'one'
  when x==2: p 'two'
  else p 'whoops!'
end
^D
"whoops!"