Ruby If, Else If Command Syntax Ruby Jeżeli else if poleceń Składnia
The Ruby language has a very simple control structure that is easy to read and follow. Języka Ruby posiada bardzo prostą strukturę kontroli, które są łatwe do odczytania i przestrzegać ich.
If syntax Jeśli składni
if var == 10 jeśli var == 10
print “Variable is 10″ print "Zmienna jest 10"
end koniec
If Else Syntax Jeśli inne Składnia
if var == 10 jeśli var == 10
print “Variable is 10″ print "Zmienna jest 10"
else w przeciwnym razie
print “Variable is something else” print "Zmienna to coś innego"
end koniec
If Else If Syntax Jeśli inne Jeśli Składnia
Here's the key difference between Ruby and most other languages. Oto kluczowa różnica między Ruby i większość innych języków. Note that “else if” is actually spelled “elsif” without the e. Zauważ, że "else if" jest rzeczywiście pisana "elsif" bez e.
if var == 10 jeśli var == 10
print “Variable is 10″ print "Zmienna jest 10"
elsif var == “20″ elsif var == "20"
print “Variable is 20″ print "Zmienna jest 20"
else w przeciwnym razie
print “Variable is something else” print "Zmienna to coś innego"
end koniec
Ternary (shortened if statement) Syntax Pieśń (skrócony if) Składnia
Ternary syntax is the same in Ruby as most languages. Pieśń składnia jest taka sama w Ruby w większości języków. The following sample will print “The variable is 10″ if var is equal to 10. W następującym przykładzie zostanie wydrukowana "zmienna jest 10" Jeśli parametr jest równy 10. Otherwise it will print “The variable is Not 10″. W przeciwnym razie będzie to print "zmienna jest nie 10".
print “The variable is ” + (var == 10 ? “10″ : “Not 10″) print "zmienna jest" + (var == 10 "10": "nie 10")

Daily Email Updates Daily Email Updates
You can get our how-to articles in your inbox each day for free. Możesz pobrać nasze instrukcje postępowania w skrzynce odbiorczej codziennie za darmo. Just enter your name and email below: Wystarczy podać swoje imię i adres e-mail:


