Created
March 3, 2015 20:00
-
-
Save Andsbf/3dee77c7cc8a9b6869db to your computer and use it in GitHub Desktop.
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 [coding_ruby]> irb | |
2.1.3 :001 > quit | |
vagrant [coding_ruby]> pry | |
[1] pry(main)> def say_hi | |
[1] pry(main)* puts "input your name" | |
[1] pry(main)* name = gets.chomp | |
[1] pry(main)* puts "hi #{name}" | |
[1] pry(main)* end | |
=> :say_hi | |
[2] pry(main)> say_hi | |
input your name | |
anderson | |
hi anderson | |
=> nil | |
[3] pry(main)> def say_hi(name) | |
[3] pry(main)* puts "input:" | |
[3] pry(main)* end | |
=> :say_hi | |
[4] pry(main)> def say_hi(name) | |
[4] pry(main)* puts "Hi #{name}" | |
[4] pry(main)* end | |
=> :say_hi | |
[5] pry(main)> say_hi(anderson) | |
NameError: undefined local variable or method `anderson' for main:Object | |
from (pry):13:in `__pry__' | |
[6] pry(main)> say_hi('anderson') | |
Hi anderson | |
=> nil | |
[7] pry(main)> clean | |
NameError: undefined local variable or method `clean' for main:Object | |
from (pry):15:in `__pry__' | |
[8] pry(main)> name | |
NameError: undefined local variable or method `name' for main:Object | |
from (pry):16:in `__pry__' | |
[9] pry(main)> name = 'Anderson' | |
=> "Anderson" | |
[10] pry(main)> name | |
=> "Anderson" | |
[11] pry(main)> clean | |
NameError: undefined local variable or method `clean' for main:Object | |
from (pry):19:in `__pry__' | |
[12] pry(main)> clear | |
NameError: undefined local variable or method `clear' for main:Object | |
from (pry):20:in `__pry__' | |
[13] pry(main)> name.sort | |
NoMethodError: undefined method `sort' for "Anderson":String | |
from (pry):21:in `__pry__' | |
[14] pry(main)> name = [1,5,4,3,2] | |
=> [1, 5, 4, 3, 2] | |
[15] pry(main)> name.sorte | |
NoMethodError: undefined method `sorte' for [1, 5, 4, 3, 2]:Array | |
from (pry):23:in `__pry__' | |
[16] pry(main)> name.sort | |
=> [1, 2, 3, 4, 5] | |
[17] pry(main)> name | |
=> [1, 5, 4, 3, 2] | |
[18] pry(main)> name.sort! | |
=> [1, 2, 3, 4, 5] | |
[19] pry(main)> name | |
=> [1, 2, 3, 4, 5] | |
[20] pry(main)> name.ins | |
name.insert name.instance_eval name.instance_of? name.instance_variable_get name.instance_variables | |
name.inspect name.instance_exec name.instance_variable_defined? name.instance_variable_set | |
[20] pry(main)> name.ins | |
name.insert name.instance_eval name.instance_of? name.instance_variable_get name.instance_variables | |
name.inspect name.instance_exec name.instance_variable_defined? name.instance_variable_set | |
[20] pry(main)> name.ins | |
name.insert name.instance_eval name.instance_of? name.instance_variable_get name.instance_variables | |
name.inspect name.instance_exec name.instance_variable_defined? name.instance_variable_set | |
[20] pry(main)> name.inspect | |
=> "[1, 2, 3, 4, 5]" | |
[21] pry(main)> name = 'Anderson' | |
=> "Anderson" | |
[22] pry(main)> name.inspect | |
=> "\"Anderson\"" | |
[23] pry(main)> help inspect | |
Error: No help found for 'inspect' | |
[24] pry(main)> name = [1,2,3,4,5,'Anderson',true] | |
=> [1, 2, 3, 4, 5, "Anderson", true] | |
[25] pry(main)> name.each |i| do | |
SyntaxError: unexpected keyword_do_block | |
[25] pry(main)> name.each |i| | |
[25] pry(main)* i + 'hi' | |
NameError: undefined local variable or method `i' for main:Object | |
from (pry):32:in `__pry__' | |
[26] pry(main)> i + 'hi' | |
NameError: undefined local variable or method `i' for main:Object | |
from (pry):34:in `__pry__' | |
[27] pry(main)> end | |
SyntaxError: unexpected keyword_end, expecting end-of-input | |
[27] pry(main)> name.each do |i| | |
[27] pry(main)* i + 1 | |
[27] pry(main)* end | |
TypeError: no implicit conversion of Fixnum into String | |
from (pry):36:in `+' | |
[28] pry(main)> puts " i + 1" | |
i + 1 | |
=> nil | |
[29] pry(main)> name.each do |i| | |
[29] pry(main)* puts " i + 1" | |
[29] pry(main)* end | |
i + 1 | |
i + 1 | |
i + 1 | |
i + 1 | |
i + 1 | |
i + 1 | |
i + 1 | |
=> [1, 2, 3, 4, 5, "Anderson", true] | |
[30] pry(main)> name.each do |i| | |
[30] pry(main)* puts " #{i} + 1" | |
[30] pry(main)* end | |
1 + 1 | |
2 + 1 | |
3 + 1 | |
4 + 1 | |
5 + 1 | |
Anderson + 1 | |
true + 1 | |
=> [1, 2, 3, 4, 5, "Anderson", true] | |
[31] pry(main)> Ma | |
Marshal MatchData Math | |
[31] pry(main)> Math.sqrt(9) | |
=> 3.0 | |
[32] pry(main)> Math.sqrt(12378) | |
=> 111.2564604865713 | |
[33] pry(main)> Math.sqrt(12379) | |
=> 111.26095451684746 | |
[34] pry(main)> Math.sqrt(12380) | |
=> 111.26544836560899 | |
[35] pry(main)> Math.sqrt(12381) | |
=> 111.26994203287786 | |
[36] pry(main)> Math.sqrt(12390) | |
=> 111.31037687475504 | |
[37] pry(main)> Math.sqrt(12400) | |
=> 111.35528725660043 | |
[38] pry(main)> 112^2 | |
=> 114 | |
[39] pry(main)> 112^^2 | |
SyntaxError: unexpected '^' | |
112^^2 | |
^ | |
[39] pry(main)> 112**2 | |
=> 12544 | |
[40] pry(main)> Math.sqrt(12544) | |
=> 112.0 | |
[41] pry(main)> time.now | |
NameError: undefined local variable or method `time' for main:Object | |
from (pry):55:in `__pry__' | |
[42] pry(main)> Time.now | |
=> 2015-03-03 19:56:56 +0000 | |
[43] pry(main)> a= Time.now | |
=> 2015-03-03 19:57:06 +0000 | |
[44] pry(main)> a | |
=> 2015-03-03 19:57:06 +0000 | |
[45] pry(main)> b=Time.now | |
=> 2015-03-03 19:57:17 +0000 | |
[46] pry(main)> b-a | |
=> 11.119101486 | |
[47] pry(main)> b | |
=> 2015-03-03 19:57:17 +0000 | |
[48] pry(main)> b.inspect | |
=> "2015-03-03 19:57:17 +0000" | |
[49] pry(main)> Array.new(10,'new') | |
=> ["new", "new", "new", "new", "new", "new", "new", "new", "new", "new"] | |
[50] pry(main)> include Ma | |
Marshal MatchData Math | |
[50] pry(main)> include Ma | |
Marshal MatchData Math | |
[50] pry(main)> include Ma | |
Marshal MatchData Math | |
[50] pry(main)> include Ma | |
Marshal MatchData Math | |
[50] pry(main)> include Math | |
=> Object | |
[51] pry(main)> sqrt 9 | |
=> 3.0 | |
[52] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment