View Review Details


Book:   Ruby in a Nutshell
Subject:   Ruby in a Nutshell Review
Date:   2003-04-22 11:19:07
From:   Paul R. Potts
Rating:  StarStarStarStarStar

Whoops, I promised in my review to provide an example of the issue that can arise in a case statement because: if a and b are not the same type, then "a === b" does not necessarily imply "b === a." This example is taken from Hal Fulton's book The Ruby Way.


<blockquote>


case /Hell/


when "Hello"


print "We matched.\n"


else


print "We didn't match.\n"


end


</blockquote>


As you might expect after that build-up, the code fragment above prints "We didn't match."


See larger cover
Browse within this book