Skip to content

Instantly share code, notes, and snippets.

@shinobcrc
Created June 21, 2016 13:40
Show Gist options
  • Save shinobcrc/ef6f95c3dd3b091a60b7cbf46ce5a9a2 to your computer and use it in GitHub Desktop.
Save shinobcrc/ef6f95c3dd3b091a60b7cbf46ce5a9a2 to your computer and use it in GitHub Desktop.
ruby gist
[1] pry(main)> def say_hi(name)
[1] pry(main)* "Hi #{name}"
[1] pry(main)* end
=> :say_hi
[2] pry(main)> say_hi("Shino")
=> "Hi Shino"
[3] pry(main)> my_number = 23
=> 23
[4] pry(main)> my_array = [1,25,61,2]
=> [1, 25, 61, 2]
[5] pry(main)> my_array.sort
=> [1, 2, 25, 61]
[6] pry(main)> my_array.sort!
=> [1, 2, 25, 61]
[7] pry(main)> my_array
=> [1, 2, 25, 61]
[8] pry(main)> new_array = [17,38,1,15]
=> [17, 38, 1, 15]
[9] pry(main)> new_array.flatten
=> [17, 38, 1, 15]
[10] pry(main)> new_array.sort
=> [1, 15, 17, 38]
[11] pry(main)> new_array.sort!
=> [1, 15, 17, 38]
[12] pry(main)> new_array.each { |word| puts word }
1
15
17
38
=> [1, 15, 17, 38]
[13] pry(main)> Math.sqrt(144)
=> 12.0
[14] pry(main)> Time.now
=> 2016-06-21 07:39:13 -0600
[15] pry(main)> Array.new(10, 'bee')
=> ["bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee"]
[16] pry(main)> include Math
=> Object
[17] pry(main)> sqrt 124
=> 11.135528725660043
[18] pry(main)> sqrt 9
=> 3.0
[19] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment