string = String.new 2.times do puts "Hello world" end
# Hello world
# Hello world
1.upto(100) { |i| puts i }
# 1
# 2
...
# 100
some_list = [String, "some string", Integer]
class Class
def some_method
puts "I'm in 'Class' class"
end
end
class Test
end
Test.some_method
# I'm in 'Class' class
people.each do |person|
if person.sick?
doctor.visit person else person.jumps_around end end
hello = Proc.new do |string|
puts "Hello #{string.upcase}"
end
hello.call 'sameer'
# Hello sameer
class String
def say_hello
puts "Hello #{self.to_s}"
end
end
"sameer".say_hello
# Hello sameer
$ gem install rails