the explaination of the keyword "then"?

I guys I was wounder I saw a keyword named "then" in ruby but I was curious of his use....so if someone can explain me what is this use I would apreciate 🙂

thanks~

all regards 

Nio Kasgami
The "then" keyword let's you write an "if" using only one line:

if x == 20 then y = 30instead of

if x == 20  y = 30endCheck this:

http://stackoverflow.com/questions/3083636/difference-between-ruby-if-statements-with-then-at-the-end
oh thanks haha!
Note that using "then" only works if the case only has one following statement. You cannot say for example

if x == 20 then y = 30

z = 30
Otherwise the Z will not be part of the case statement, If you wanted to include the Z in the case, it has to be:

if x == 20

  y = 20

  z = 30

end
Also note that you do not use "end" with "then".
The keyword then can be used with if, unless, case/when and rescue expressions, but it's optional. As Hudell already has mentioned, it's useful to put code into the same line. then is one way to achieve that, since otherwise Ruby doesn't know which piece of code is the controlling expression / conditional and which piece is the code that gets executed (the then-clause). Usually a line terminator is used, but then they can't be on the same line! The other way is a bit uglier: a semicolon. There was another way in old Ruby versions (a colon), however it has been removed.

It's rarely used except with (simple) case-expressions:

Code:
current_rpgmaker =  case year  when 1997..1999 then '95'  when 2000..2001 then '2000'  when 2002..2003 then '2003'  when 2004..2006 then 'XP'  when 2007..2010 then 'VX'  when 2011..2015 then 'VX Ace'  else 'unknown'  end
wow then this a really cool explaination thanks guys : D 

but yeah for me then = "donc" in english so this was more

if my variable equal 10 then my other variable equal 10
Most of the time you should just use suffix expressions:

Code:
foo = bar if baz
Most of the time you should just use suffix expressions:

foo = bar if baz
well this was more for know is use sincerelly haha because I am always curious on that!

Original thread: https://forums.rpgmakerweb.com/threads/the-explaination-of-the-keyword-then.37703/