From: Phillip Gawlowski Date: 2008-06-06T02:39:01+09:00 Subject: Re: why cannot i put conditions in when clause -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Junkone wrote: | irb(main):003:0> case a | irb(main):004:1> when 0 | irb(main):005:1> puts "0" | irb(main):006:1> when >0 | irb(main):007:1> puts "greater" | irb(main):008:1> end | SyntaxError: compile error | (irb):6: syntax error, unexpected '>' | when >0 | ^ | from (irb):8 | That's what if..else..end is there for. In a case statement you usually check against 'known' and well-defined states. Also, once a condition is met in a case statement, no other branches are evaluated. So, if you had 'when < 1' that wouldn't be evaluated, even id a = 2. - -- Phillip Gawlowski Twitter: twitter.com/cynicalryan Blog: http://justarubyist.blogspot.com 10 years old is a good age to get stuck at. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkhIJQMACgkQbtAgaoJTgL/PdACgl0ZgF5lF/X8wKPql1h/+Y+/s BbcAn3KLQdeiCg2iYEsx2jr1MzKsBLPY =L4oU -----END PGP SIGNATURE-----