Subscribe to How-To Geek Mag-subscribe sa Paano-Upang Geek

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 Ruby Kung, Pa Kung Command Syntax

The Ruby language has a very simple control structure that is easy to read and follow. Ang Ruby wika ay isang napaka-simpleng istraktura ng control na madaling basahin at sundin.

If syntax Kung syntax

if var == 10 kung var == 10
print “Variable is 10″ print "variable 10"
end wakasan

If Else Syntax Kung Iba Pa Syntax

if var == 10 kung var == 10
print “Variable is 10″ print "variable 10"
else kung hindi
print “Variable is something else” print "variable ay isang bagay sino pa ang paririto"
end wakasan

If Else If Syntax Kung Iba Pa Kung Syntax

Here's the key difference between Ruby and most other languages. Narito ang susi pagkakaiba sa pagitan ng Ruby at karamihan sa mga ibang wika. Note that “else if” is actually spelled “elsif” without the e. Tandaan na "kung sino pa ang paririto" ay ang tunay na spelling "elsif" walang e.

if var == 10 kung var == 10
print “Variable is 10″ print "variable 10"
elsif var == “20″ elsif var == "20"
print “Variable is 20″ print "variable 20"
else kung hindi
print “Variable is something else” print "variable ay isang bagay sino pa ang paririto"
end wakasan

Ternary (shortened if statement) Syntax Tatlong bagay (pinaikling kung ang pahayag) Syntax

Ternary syntax is the same in Ruby as most languages. Tatlong bagay na syntax ay pareho sa Ruby tulad ng karamihan ng mga wika. The following sample will print “The variable is 10″ if var is equal to 10. Ang mga sumusunod ay mga halimbawang print "Ang mga variable ay 10" kung var ay pantay-pantay na sa 10. Otherwise it will print “The variable is Not 10″. Kung hindi, ito ay naka-print "variable ay 10 Hindi".

print “The variable is ” + (var == 10 ? “10″ : “Not 10″) print "variable ay" + (var == 10? "10": "Hindi 10")

This article was originally written on 11/1/09 Tagged with: Ang artikulong ito ay orihinal na isinulat sa 11/1/09 Tagged with: Ruby Ruby

Daily Email Updates Araw-araw na Updates Email

You can get our how-to articles in your inbox each day for free. Maaari kang makakuha ng aming kung-paano na mga artikulo sa iyong inbox sa bawat araw para sa libre. Just enter your name and email below: Ilagay lamang ang inyong pangalan at email sa ibaba:


Name: Pangalan:
Email: Email:

Leave a Comment Iwanan ng isang Puna




Leave your Iwanan ang iyong mga friendly friendly comment here. puna dito.

If you have a computer help question, Kung ikaw ay may isang computer ng tulong tanong, click here to leave it on the forums i-click dito upang mag-iwan ito sa forums instead. sa halip ng.

Note: Your comment may not show up immediately on the site. Tandaan: Ang iyong puna ay maaaring hindi magpapakita agad sa site.

Our Friends Ang aming mga Friends
Getting Started Pagsisimula


About How-To Geek Tungkol sa Paano-Upang Geek
What Is That Process? Ano ba ang Proseso Iyon?
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. Copyright © 2006-2009 HowToGeek.com. All Rights Reserved. All Rights Reserved.