Saturday, April 14, 2012

[Ruby] Case Syntax

          Hello, Reader ^^! Back again with source code. This time is a basic syntax Case in Ruby programming language. This source code is to show how to do Case statement in Ruby language. Here's the template:



case <variable name>
   when <variable condition 1> then
       <statement 1 if variable fulfills condition 1>
   when <variable condition 2> then
       <statement 2 if variable fulfills condition 2>
   when  <variable condition 3> then
       <statement 3 if variable fulfills condition 3>
   when  <variable condition 4> then
       <statement 4 if variable fulfills condition 4>
   when  <variable condition N> then
       <statement N if variable fulfills condition N>
   else
       <statement if variable doesn't fulfill any condition>
end


Note: "else" is optional


Okay, that's all I can say. Thank you for reading ^^!

Download/View Source Code
Dropbox
Dropbox (Repository)
GitHub
GitHub (Repository)







No comments:

Post a Comment