F
F
Fa1c2015-11-09 23:14:48
ruby
Fa1c, 2015-11-09 23:14:48

What does then mean in Ruby?

Switched to ruby. I see the following construction:
if 'there is some condition' then
puts 'bla bla bla'
end
then - it is not necessary to write and it refers to the if, or is it used somewhere else, do I think it right?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Demidenko, 2015-11-09
@Fa1c

then is needed if you want to use if in one line

val = 5
puts (if val == 1 then '1' else 'Not 1' end)

Also used in case

S
Sergey, 2015-11-09
Protko @Fesor

then - not required to be written and refers to ifu,

Is it true? It's not clear from the documentation.
This is convenient for bringing the code closer to the business language. For example, something along the lines of
Just allows the code to be more expressive and more clearly describe your thought in the code in terms of the English language.

P
Pavel Grudinkin, 2015-11-09
@Hunt666

www.tutorialspoint.com/ruby/ruby_if_else.htm what's in square brackets is optional

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question