ruby for programmers code example

Example 1: ruby for programmers

irb(main):001:0> "Hello World"
=> "Hello World"

Example 2: ruby for programmers

irb(main):007:0> a = 3 ** 2
=> 9
irb(main):008:0> b = 4 ** 2
=> 16
irb(main):009:0> Math.sqrt(a+b)
=> 5.0

Example 3: ruby for programmers

irb(main):006:0> Math.sqrt(9)
=> 3.0

Example 4: ruby for programmers

irb(main):005:0> 3**2
=> 9

Example 5: ruby for programmers

irb(main):004:0> 3*2
=> 6

Example 6: ruby for programmers

irb(main):003:0> 3+2
=> 5

Example 7: ruby for programmers

irb(main):002:0> puts "Hello World"
Hello World
=> nil

Tags:

Misc Example