Meet Ruby...She's sometimes quirky, always beautiful, a little mysterious, and absolutely magical. Think Mary Poppins..
...programming was fun again...
Strong or Weak?
4.class
'four'.class
4 + 'four'
Dynamic or Static?
def add_them_up
4 + 'four'
end
add_them_up
Dynamic or Static?
i = 0
a = ['100', 100.0]
while i < 2
puts a[i].to_i
i = i + 1
end
Purely Object-Oriented
Interpreted
puts "Hello, World!"
language = "Ruby"
puts "hello, #{language}"
4.methods
x = 4
puts 'This appears to be false.' unless x == 4
puts 'This appears to be true.' if x == 4
if x == 4
puts 'This appears to be true.'
end
unless x == 4
puts 'This appears to be false.'
else
puts 'This appears to be true.'
end
puts 'This appears to be true.' if not true
puts 'This appears to be true.' if !true
x = x + 1 while x < 10
x = x - 1 until x == 1
while x < 10
x = x + 1
puts x
end
Everything but nil and false evaluate to true.