The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Wonder of the When-Be-Splat

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Wonder of the When-Be-Splat Posted: Feb 23, 2006 6:05 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Wonder of the When-Be-Splat
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

Well, okay, yes, we already know Ruby is expressive. And, if I know you, you’ll see a drop of awesomeness in:

 BOARD_MEMBERS = ['Jan', Julie', 'Archie', 'Stewick']
 HISTORIANS = ['Braith', 'Dewey', 'Eduardo']

 case name
 when *BOARD_MEMBERS
   "You're on the board!  A congratulations is in order." 
 when *HISTORIANS
   "You are busy chronicling every deft play." 
 end

I was refactoring a parser and it occured to me that I could just do a when *tokens.keys at one point. Ruby treats it just like a list of conditions. Consider Olympic ice dancing out-graced!

Read: Wonder of the When-Be-Splat

Topic: Chapter 9 Previous Topic   Next Topic Topic: Chapter 8

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use