Important! This is an automatic machine translated page. If you can read english, you should Click Here to read the original English version of the article.

Ruby If, Else If Command Syntax紅寶石如果,否則如果命令語法

The Ruby language has a very simple control structure that is easy to read and follow. Ruby語言有一個很簡單的控制結構,易於閱讀和遵循。

If syntax 如果語法

if var == 10如果var == 10
print “Variable is 10″打印“變量是10”
end末端

If Else Syntax 如果拍賣品語法

if var == 10如果var == 10
print “Variable is 10″打印“變量是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.請注意,“否則,如果”實際上是拼寫“elsif”,不包括大腸桿菌

if var == 10如果var == 10
print “Variable is 10″打印“變量是10”
elsif var == “20″ elsif無功==“20”
print “Variable is 20″打印“變量是20”
else其他的
print “Variable is something else”印刷版“變是另外一回事”
end末端

Ternary (shortened if statement) Syntax 三元(縮短if語句)語法

Ternary syntax is the same in Ruby as most languages.三元語法是相同的,因為大多數的Ruby語言。 The following sample will print “The variable is 10″ if var is equal to 10.下面的示例將打印“這個變量是10”如果var等於10。 Otherwise it will print “The variable is Not 10″.否則,將打印“這個變量是不是10”。

print “The variable is ” + (var == 10 ? “10″ : “Not 10″)印刷版“的變量是”+(無功== 10?“10”:“不是10”)

This article was originally written on 11/13/09 Tagged with: 本文最初寫在11/13/09 標籤: Ruby 紅寶石

Daily Email Updates每日電子郵件更新

You can get our how-to articles in your inbox each day for free.你可以得到我們的指導性文章在您的收件箱每天免費。 Just enter your name and email below:只要輸入您的姓名和電子郵件如下:


Name:名稱:
Email:電子郵件:

Leave a Comment發表評論




Leave your留下您的 friendly友好 comment here.在這裡評論。

If you have a computer help question,如果你有一台計算機的問題, click here to leave it on the forums點擊這裡留下它論壇 instead.代替。

Note: Your comment may not show up immediately on the site. 注意:您的評論可能不會立即顯示在網站上。

Our Friends我們的朋友
Getting Started入門


About How-To Geek關於如何到奇客
What Is That Process?那是什麼過程?
svchost.exe Svchost.exe的
jusched.exe jusched.exe
dwm.exe dwm.exe
ctfmon.exe Ctfmon.exe的
wmpnetwk.exe wmpnetwk.exe
wmpnscfg.exe wmpnscfg.exe
rundll32.exe Rundll32.exe的
wfcrun32.exe wfcrun32.exe
Ipoint.exe Ipoint.exe
Itype.exe Itype.exe
Wfica32.exe Wfica32.exe
Mobsync.exe Mobsync.exe
conhost.exe conhost.exe
Dpupdchk.exe Dpupdchk.exe Adobe_Updater.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com.版權所有© 2006-2009 HowToGeek.com。 All Rights Reserved.保留所有權利。