• ≡ Menu
  • Contact
  • Sitemap
  • Advertise
  • Submenu
    • Submenu 1
    • Submenu 2
    • Submenu 3
    • Submenu 4
    • Submenu 5
  • Submenu
    • Submenu 1
    • Submenu 2
    • Submenu 3
    • Submenu 4
    • Submenu 5
  • Submenu
    • Submenu 1
    • Submenu 2
    • Submenu 3
    • Submenu 4
    • Submenu 5

شارع

Menu
  • Static Page
  • Dropmenu
    • Dropmenu 1
    • Dropmenu 2
    • Dropmenu 3
    • Dropmenu 4
    • Dropmenu 5
  • Button
  • Dropmenu
    • Dropmenu 1
    • Dropmenu 2
    • Dropmenu 3
    • Dropmenu 4
    • Dropmenu 5
  • Error
  • Surprise Me
Linux Ruby If, Else If Command Syntax

Ruby If, Else If Command Syntax

The Ruby language has a very simple control structure that is easy to read and follow.

  If syntax
if var == 10
print “Variable is 10”
end

If Else Syntax
if var == 10
print “Variable is 10”
else
print “Variable is something else”
end

If Else If Syntax
 Here’s the key difference between Ruby and most other languages. Note that “else if” is actually spelled “elsif” without the e.

if var == 10
print “Variable is 10”
elsif var == “20”
print “Variable is 20”
else
print “Variable is something else”
end

Ternary (shortened if statement) Syntax

 Ternary syntax is the same in Ruby as most languages. The following sample will print “The variable is 10” if var is equal to 10. Otherwise it will print “The variable is Not 10”.

print “The variable is ” + (var == 10 ? “10” : “Not 10”)

wh76
Add Comment
Linux
Monday, March 21, 2016
  • Tweet
  • Share
  • Share
  • Share
  • Share

About Admin

This is dummy text. It is not meant to be read. Accordingly, it is difficult to figure out when to end it. But then, this is dummy text. It is not meant to be read. Period.

Related Posts

Comments
0 Comments

Follow on FaceBook

Weekly Posts

  • Ruby If, Else If Command Syntax
    Ruby If, Else If Command Syntax
    The Ruby language has a very simple control structure that is easy to read and follow.   If syntax if var == 10 print “Variable is 10” end...
  • Responsive CSS Timeline with 3D Effect for Blogger
    Responsive CSS Timeline with 3D Effect for Blogger
    Here's another amazing way to display our Blogger posts. By applying the following Responsive CSS Timeline View with 3D Effect on Blogge...
  • How to Install Fallout 4 Mods with Nexus Mod Manager
    How to Install Fallout 4 Mods with Nexus Mod Manager
    Like Skyrim and other Bethesda games before it, modding is one of Fallout 4’s huge draws on the PC. But Fallout 4 and Steam don’t offer an e...
  • How to Turn off “OK Google” on Your Android Device
    How to Turn off “OK Google” on Your Android Device
    “Ok Google” is cool because it just works. The hands-free search activation installed on the vast majority of Android devices makes looking ...
  • Fast Food Tri-Fold Brochure PSD Template
    Fast Food Tri-Fold Brochure PSD Template
    Fast Food Tri-Fold Brochure PSD Template PSD | 1275x1875 PIX | 14,73 MB DOWNLOAD
  • Add Masonry, Grid Layouts to Blogger Posts with CSS and Javascript
    Add Masonry, Grid Layouts to Blogger Posts with CSS and Javascript
    How a website's content is displayed can spell the difference between being popular and obscure. Anything that looks chaotic or hardly r...
  • How to Make Windows Play a Sound When You Press Caps Lock, Num Lock, or Scroll Lock
    How to Make Windows Play a Sound When You Press Caps Lock, Num Lock, or Scroll Lock
    Have you ever turned on the Caps Lock key ACCIDENTALLY WHILE YOU’RE TYPING? Or turned off the Num Lock key unintentionally and then tried to...
  • How to Add Emoticons/Smileys in Blogger Comments
    How to Add Emoticons/Smileys in Blogger Comments
    Emoticons/Smileys are a great way of making discussions more interesting and fun, so it's a pity that Blogger don't support them. In...
  • InstaShow v1.4.1 - WordPress Instagram Gallery Widget
    InstaShow v1.4.1 - WordPress Instagram Gallery Widget
    InstaShow is a premium Instagram widget for creating charming galleries of Instagram images. Take the advantage of an all-new multipurpose G...
  • How to Read a Mac-Formatted Drive on a Windows PC
    How to Read a Mac-Formatted Drive on a Windows PC
    Windows can’t normally read Mac-formatted drives, and will offer to erase them instead. But third-party tools fill the gap and provide acces...

Label

Android Android Games Apple Blogger Ebooks Flac Gadgets Graphics Hardware Jazz Linux MakeMoney Mobiles Office PC Games Script suf Templates Windows

Visitor

Sparkline

Subscribe Box

Contact

Name

Email *

Message *

Copyright شارع 2014-2015
Created by Arlina Design