Jump to content

User talk:Paopao86

Add topic
From mediawiki.org

HOW TO DECLARE VARIABLE IN RUBY PROGRAMMING LANGUAGE

You can manipulate variables in exactly the same way that you would manipulate the objects that they represent.

Ruby Gem

'>>var1=7 =>7 >>var2=4 =>4


>>var3 = var1 + var 2 =>11


>>var = "hello" => "hello" >> var4 = var4 * var2 => hellohellohellohellohello



>> num1 = 2 + 4 + 6 + 8 => 20 >> num1 = num1/5 => 24 >> num2 = num2 - num1 =>20


 

num1 = num1 / 5 num2 = num2 - num1    These kinds of expressions are very common, so Ruby offers you some shortcuts:

Example Shortcut Meaning var = var + 2 var += 2 Add 2 to var var = var - 3 var -= 3 Subtract 3 from var var = var * 6 var *= 6 Multiply var by 6 var = var / 2 var /= 2 Divide var by 2 var = var** 3 var **=3 Cube var var = var % 4 var %= 4 var modulo 4

http://myblogpaopao86.blogspot.com/ By: John Paul Mamaril

Start a discussion with Paopao86

Start a discussion