Skip to content

Instantly share code, notes, and snippets.

@brianbancroft
Created March 29, 2016 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianbancroft/35f04371ec5feba2b76c to your computer and use it in GitHub Desktop.
Save brianbancroft/35f04371ec5feba2b76c to your computer and use it in GitHub Desktop.
Playing around with Ruby command line
vagrant [tu (master)⚡]> pry
[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)> my_array
=> [5, 3, 7, 2]
[4] pry(main)> my_array.sort!
=> [2, 3, 5, 7]
[5] pry(main)> include Math
=> Object
[6] pry(main)> from Math import Math
NoMethodError: undefined method `import' for main:Object
from (pry):6:in `__pry__'
[7] pry(main)> Math.sqrt(2)
=> 1.4142135623730951
[8] pry(main)> Math.sqrt(-1)
Math::DomainError: Numerical argument is out of domain - "sqrt"
from (pry):8:in `sqrt'
[9] pry(main)> puts "Problems? Must be my imagination..."
Problems? Must be my imagination...
=> nil
[10] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment