Created
June 21, 2016 18:28
-
-
Save FioFiyo/cb673e1a8f9b9b40f9581d2233236219 to your computer and use it in GitHub Desktop.
Testing pry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant [vagrant]> pry | |
[1] pry(main)> "hello" | |
=> "hello" | |
[2] pry(main)> puts "h" | |
h | |
=> nil | |
[3] pry(main)> quit | |
vagrant [vagrant]> ls | |
git-mania scavenger_hunt-master temp_test_file.txt Vagrantfile | |
vagrant [vagrant]> touch example.rb | |
vagrant [vagrant]> ls | |
example.rb git-mania scavenger_hunt-master temp_test_file.txt Vagrantfile | |
vagrant [vagrant]> ruby example.rb | |
this is the firs rb file, type your name:fio | |
Hello fio | |
vagrant [vagrant]> pry | |
[1] pry(main)> def say_hi(name) | |
[1] pry(main)* puts "hi there, #{name}" | |
[1] pry(main)* end | |
=> :say_hi | |
[2] pry(main)> greet =say_hi("george") | |
hi there, george | |
=> nil | |
[3] pry(main)> say_hi('fio') | |
hi there, fio | |
=> nil | |
[4] pry(main)> array = [1,5,3,8] | |
=> [1, 5, 3, 8] | |
[5] pry(main)> array.sort | |
=> [1, 3, 5, 8] | |
[6] pry(main)> array | |
=> [1, 5, 3, 8] | |
[7] pry(main)> array.sort! | |
=> [1, 3, 5, 8] | |
[8] pry(main)> array | |
=> [1, 3, 5, 8] | |
[9] pry(main)> array = ["a","c","b"] | |
=> ["a", "c", "b"] | |
[10] pry(main)> array.sort | |
=> ["a", "b", "c"] | |
[11] pry(main)> array | |
=> ["a", "c", "b"] | |
[12] pry(main)> array.sort! | |
=> ["a", "b", "c"] | |
[13] pry(main)> array | |
=> ["a", "b", "c"] | |
[14] pry(main)> array = ["hello","human","whatsup"] | |
=> ["hello", "human", "whatsup"] | |
[15] pry(main)> array.each {|greet| puts greet} | |
hello | |
human | |
whatsup | |
=> ["hello", "human", "whatsup"] | |
[16] pry(main)> array.each {|greet\n| puts greet} | |
SyntaxError: unexpected tIDENTIFIER, expecting keyword_do or '{' or '(' | |
array.each {|greet\n| puts greet} | |
^ | |
[16] pry(main)> Math.sqrt(1282) | |
=> 35.805027579936315 | |
[17] pry(main)> Time.now | |
=> 2016-06-21 18:17:57 +0000 | |
[18] pry(main)> Time.yesterday | |
NoMethodError: undefined method `yesterday' for Time:Class | |
from (pry):20:in `__pry__' | |
[19] pry(main)> Time | |
=> Time | |
[20] pry(main)> Time.now | |
=> 2016-06-21 18:18:08 +0000 | |
[21] pry(main)> Array.new(0,"yes") | |
=> [] | |
[22] pry(main)> Array | |
=> Array | |
[23] pry(main)> Array.new(0,"yes","abc") | |
ArgumentError: wrong number of arguments (given 3, expected 0..2) | |
from (pry):25:in `initialize' | |
[24] pry(main)> Array.new("yes","abc") | |
TypeError: no implicit conversion of String into Integer | |
from (pry):26:in `initialize' | |
[25] pry(main)> Array.new(2,"yes","abc") | |
ArgumentError: wrong number of arguments (given 3, expected 0..2) | |
from (pry):27:in `initialize' | |
[26] pry(main)> Array.new(3,"yes","abc") | |
ArgumentError: wrong number of arguments (given 3, expected 0..2) | |
from (pry):28:in `initialize' | |
[27] pry(main)> Array.new(10,'bee') | |
=> ["bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee"] | |
[28] pry(main)> Array.new('bee') | |
TypeError: no implicit conversion of String into Integer | |
from (pry):30:in `initialize' | |
[29] pry(main)> Array.new('bee','bear') | |
TypeError: no implicit conversion of String into Integer | |
from (pry):31:in `initialize' | |
[30] pry(main)> Array.new(10,'bee') | |
=> ["bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee", "bee"] | |
[31] pry(main)> Array.new(10,2) | |
=> [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] | |
[32] pry(main)> Array.new(0,"yes") | |
=> [] | |
[33] pry(main)> Array.new(1,"yes") | |
=> ["yes"] | |
[34] pry(main)> include Math | |
=> Object | |
[35] pry(main)> sqrt 8 | |
=> 2.8284271247461903 | |
[36] pry(main)> sum 1,2 | |
NoMethodError: undefined method `sum' for main:Object | |
from (pry):38:in `__pry__' | |
[37] pry(main)> sum 1 2 | |
SyntaxError: unexpected tINTEGER, expecting end-of-input | |
[37] pry(main)> sum 1 | |
NoMethodError: undefined method `sum' for main:Object | |
from (pry):39:in `__pry__' | |
[38] pry(main)> sum(1,2) | |
NoMethodError: undefined method `sum' for main:Object | |
from (pry):40:in `__pry__' | |
[39] pry(main)> include Math | |
=> Object | |
[40] pry(main)> sqrt 10 | |
=> 3.1622776601683795 | |
[41] pry(main)>quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment