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 Jei else if komandos sintaksė

The Ruby language has a very simple control structure that is easy to read and follow. Ruby kalba yra labai paprasta valdymo struktūrą, kad būtų lengva skaityti ir sekti.

If syntax Jei sintaksė

if var == 10 jei var == 10
print “Variable is 10″ print "Kintamasis 10"
end pabaiga

If Else Syntax IF ELSE Sintaksė

if var == 10 jei var == 10
print “Variable is 10″ print "Kintamasis 10"
else kitas
print “Variable is something else” print "Kintamasis yra kažkas"
end pabaiga

If Else If Syntax Jei else if sintaksė

Here's the key difference between Ruby and most other languages. Čia yra pagrindinis skirtumas tarp Ruby ir daugelis kitų kalbų. Note that “else if” is actually spelled “elsif” without the e. Atkreipkite dėmesį, kad "nors jei" iš tiesų yra parašytas "elsif" be E.

if var == 10 jei var == 10
print “Variable is 10″ print "Kintamasis 10"
elsif var == “20″ elsif var == "20"
print “Variable is 20″ print "Kintamasis 20"
else kitas
print “Variable is something else” print "Kintamasis yra kažkas"
end pabaiga

Ternary (shortened if statement) Syntax Trivietis (sutrumpintas, jeigu pareiškimas) Sintaksė

Ternary syntax is the same in Ruby as most languages. Ternary sintaksė Ruby pat, kaip dauguma kalbų. The following sample will print “The variable is 10″ if var is equal to 10. Šie pavyzdžiai bus išspausdinti "kintamasis yra 10", jei var yra lygus 10. Otherwise it will print “The variable is Not 10″. Priešingu atveju jis bus išspausdinti "kintamasis yra ne 10".

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

This article was originally written on 11/16/09 Tagged with: Šis straipsnis buvo parašytas ant 11/16/09 Tagged with: Ruby Ruby

Daily Email Updates Dienos paštas Atnaujinimai

You can get our how-to articles in your inbox each day for free. Galite gauti mūsų kaip prie straipsnių į Jūsų pašto dėžutę kasdien nemokamai. Just enter your name and email below: Tiesiog įveskite vardą ir elektroninio pašto adresą žemiau:


Name: Vardas:
Email: Paštas:

Leave a Comment Palikite komentarą




Leave your Palikite friendly draugiškas comment here. komentarus.

If you have a computer help question, Jei turite kompiuteryje Pagalba klausimą, click here to leave it on the forums Spauskite čia, jei norite palikti jį dėl forumai instead. vietoj.

Note: Your comment may not show up immediately on the site. Pastaba: Jūsų komentaras gali būti rodomas iš karto svetainėje.

Our Friends Mūsų draugai
Getting Started Paruo


About How-To Geek Apie How-To Geek
What Is That Process? Kas yra šis procesas?
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.