<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 3 Aug 2011, at 12:12, Matthew Rudy Jacobs wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On 3 August 2011 12:09, Tom Stuart <span dir="ltr"><<a href="mailto:tom@therye.org">tom@therye.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div><div><div><br></div><div>See page 141 of the pickaxe for this use of case.</div><div><br></div><div>Cheers,</div><div><br></div><font color="#888888"><div>Tom</div></font></div><div>

<div></div><div class="h5"><br></div></div></div></div></blockquote><div>Please enlighten me, then.</div><div>What's the usecase?</div><div><br></div><div>Have never seen this done. </div></div></blockquote><br></div><div>According to the Pickaxe '[this] form is fairly close to a series of if statements; it lets you list a series of conditions and execute a statement corresponding to the first one that's true."</div><div><br></div><div>The code example there is:</div><div><br></div><div>case</div><div>when <a href="http://song.name">song.name</a> == "Misty"</div><div>  puts "Not again!"</div><div>when song.duration > 120</div><div>  puts "Too long!"</div><div>when Time.now.hour > 21</div><div>  puts "It's too late"</div><div>else</div><div>  song.play</div><div>end</div><div><br></div><div>It's pretty ugly, but it's valid Ruby and has nothing to do with the more usual use of case for comparison with === against multiple values.</div><div><br></div><div>Cheers,</div><div><br></div><div>Tom</div><br></body></html>