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-li, Else If Command Syntax

The Ruby language has a very simple control structure that is easy to read and follow. Jazyk Ruby má veľmi jednoduché ovládanie štruktúry, ktorá je ľahko čitateľný a nasledovať.

If syntax Ak sa syntaxe

if var == 10 Ak var == 10
print “Variable is 10″ print "Premenná je 10"
end koniec

If Else Syntax If Else Syntax

if var == 10 Ak var == 10
print “Variable is 10″ print "Premenná je 10"
else iné
print “Variable is something else” print "Premenná je niečo iné"
end koniec

If Else If Syntax If Else Ak Syntax

Here's the key difference between Ruby and most other languages. Tu je kľúčový rozdiel medzi Ruby a väčšinu ostatných jazykov. Note that “else if” is actually spelled “elsif” without the e. Uvedomte si, že "elseif" je vlastne napísal "elsif" bez e.

if var == 10 Ak var == 10
print “Variable is 10″ print "Premenná je 10"
elsif var == “20″ elsif var == "20"
print “Variable is 20″ print "Premenná je 20"
else iné
print “Variable is something else” print "Premenná je niečo iné"
end koniec

Ternary (shortened if statement) Syntax Terciální (skrátené, ak vyhlásenie) Syntax

Ternary syntax is the same in Ruby as most languages. Ternární syntax je rovnaká ako v Ruby väčšine jazykov. The following sample will print “The variable is 10″ if var is equal to 10. Nasledujúca ukážka bude tlačiť "premenná je 10", ak var sa rovná 10. Otherwise it will print “The variable is Not 10″. Inak to bude tlačiť "premenná nie je 10".

print “The variable is ” + (var == 10 ? “10″ : “Not 10″) print "premenná je" + (var == 10? "10": "Nie 10")

This article was originally written on 11/13/09 Tagged with: Tento článok bol pôvodne napísaný na 11/13/09 Tagged s: Ruby Ruby

Daily Email Updates Denný Svářeč

You can get our how-to articles in your inbox each day for free. Môžete si naše jak-na články vo vašej schránky každý deň zadarmo. Just enter your name and email below: Stačí zadať svoje meno a e-mail nižšie:


Name: Meno:
Email: E-mail:

Leave a Comment Zanechať komentár




Leave your Zanechajte svoj friendly priateľský comment here. komentár tu.

If you have a computer help question, Ak máte počítač pomôže otázku, click here to leave it on the forums kliknite tu nechať to na fórach instead. miesto.

Note: Your comment may not show up immediately on the site. Poznámka: Váš komentár sa nezobrazia okamžite na mieste.

Our Friends Naši priatelia
Getting Started Začíname


About How-To Geek O tom, ako-To Geek
What Is That Process? Čo je to za proces?
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.