Subscribe to How-To Geek Підписатись на How-To 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 Якщо Else If Синтаксис команди

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” Друк "Variable-небудь інше"
end кінець

If Else If Syntax Якщо Else If Синтаксис

Here's the key difference between Ruby and most other languages. Ось основна відмінність між Рубі і більшість інших Мови. Note that “else if” is actually spelled “elsif” without the e. Відзначимо, що "інше, якщо" насправді пишеться "ELSIF" без e.

if var == 10 Якщо Var == 10
print “Variable is 10″ Друк "Змінна 10"
elsif var == “20″ ELSIF VAR == "20"
print “Variable is 20″ Друк "Змінна 20"
else ще
print “Variable is something else” Друк "Variable-небудь інше"
end кінець

Ternary (shortened if statement) Syntax Потрійні (скорочений, якщо заява) Синтаксис

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″) Друк "змінної" + (VAR == 10? "10": "Не 10")

This article was originally written on 11/12/09 Tagged with: Ця стаття була спочатку написана на 11/12/09 тегами: Ruby Ruby

Daily Email Updates Email Щоденні оновлення

You can get our how-to articles in your inbox each day for free. Ви можете отримати наші довідкові статті у Вашу поштову скриньку щодня безкоштовно. Just enter your name and email below: Просто введіть ваші ім'я та адресу електронної пошти нижче:


Name: Ім'я:
Email: Електронна пошта:

Our Friends Наші друзі
Getting Started Приступаючи до роботи


About How-To Geek Про 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. Copyright © 2006-2009 HowToGeek.com. All Rights Reserved. Всі права захищені.