Skip to content

Instantly share code, notes, and snippets.

@gbrl
Created April 26, 2016 15:04
Show Gist options
  • Save gbrl/36389a9c7a25c61390b7e80cfbfe6bc1 to your computer and use it in GitHub Desktop.
Save gbrl/36389a9c7a25c61390b7e80cfbfe6bc1 to your computer and use it in GitHub Desktop.
2.2.0 :001 > def sayhi
2.2.0 :002?> puts "HI!"
2.2.0 :003?> end
=> :sayhi
2.2.0 :004 > def greeting(name)
2.2.0 :005?> puts "Hi, #{name}."
2.2.0 :006?> end
=> :greeting
2.2.0 :007 > greeting("Bill")
Hi, Bill.
=> nil
2.2.0 :008 > [1,2,3,4]
=> [1, 2, 3, 4]
2.2.0 :009 > [1,2,3,4].sort
=> [1, 2, 3, 4]
2.2.0 :010 > array = [1,2,3,5]
=> [1, 2, 3, 5]
2.2.0 :011 > array.sort
=> [1, 2, 3, 5]
2.2.0 :012 > array = [123,23,3,5]
=> [123, 23, 3, 5]
2.2.0 :013 > array.sort
=> [3, 5, 23, 123]
2.2.0 :014 > array
=> [123, 23, 3, 5]
2.2.0 :015 > array.sort!
=> [3, 5, 23, 123]
2.2.0 :016 > array
=> [3, 5, 23, 123]
2.2.0 :017 > an_array = ["James","Lucy","John","Katie"]
=> ["James", "Lucy", "John", "Katie"]
2.2.0 :018 > an_array.each {|w| puts w}
James
Lucy
John
Katie
=> ["James", "Lucy", "John", "Katie"]
2.2.0 :019 > Math.sqrt(1282)
=> 35.805027579936315
2.2.0 :020 > Time.now
=> 2016-04-26 11:01:33 -0400
2.2.0 :021 > Time.tomorrow
NoMethodError: undefined method `tomorrow' for Time:Class
from (irb):21
from /Users/gabrielrambert/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'
2.2.0 :022 > Time.yesterday
NoMethodError: undefined method `yesterday' for Time:Class
from (irb):22
from /Users/gabrielrambert/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'
2.2.0 :023 > t = Time.now
=> 2016-04-26 11:02:46 -0400
2.2.0 :024 > t.day
=> 26
2.2.0 :025 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment