Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Olgaliber/21fb52a99ac08a03588c0ad26b35a19d to your computer and use it in GitHub Desktop.
Save Olgaliber/21fb52a99ac08a03588c0ad26b35a19d to your computer and use it in GitHub Desktop.
[1] pry(main)> my_array = [5, 3, 7, 2]
=> [5, 3, 7, 2]
[2] pry(main)> my_array.sort
=> [2, 3, 5, 7]
[3] pry(main)> an_array = ['Hello', 'nurse', 'and','world']
=> ["Hello", "nurse", "and", "world"]
[4] pry(main)> an_array.each { |word| puts word}
Hello
nurse
and
world
=> ["Hello", "nurse", "and", "world"]
[5] pry(main)>
[6] pry(main)> an_array
=> ["Hello", "nurse", "and", "world"]
[7] pry(main)> math.sqrt(1282)
NameError: undefined local variable or method `math' for main:Object
from (pry):6:in `__pry__'
[8] pry(main)> Math.sqrt(1282)
=> 35.805027579936315
[9] pry(main)> Time.now
=> 2016-05-24 21:24:31 +0000
[10] pry(main)> Array.new(10, 'bee')
=> ["bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee"]
[11] pry(main)> Array.new(5, 'hello')
=> ["hello", "hello", "hello", "hello", "hello"]
[12] pry(main)> include Math
=> Object
[13] pry(main)> sqrt 64
=> 8.0
[14] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment