Created
February 10, 2016 18:39
-
-
Save worace/537afaea07c8df3f94e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| [3] pry(#<ModuleOneInstructor>)> def | |
| [3] pry(#<ModuleOneInstructor>)> exit | |
| => nil | |
| [163] pry(main)> def method_one(param1, param2) | |
| [163] pry(main)* end | |
| => :method_one | |
| [164] pry(main)> class | |
| [164] pry(main)> exit | |
| worace @ Turing ➸ pry | |
| [1] pry(main)> class MyObject | |
| [1] pry(main)* def my_method(one, two) | |
| [1] pry(main)* one = nil | |
| [1] pry(main)* two = nil | |
| [1] pry(main)* end | |
| [1] pry(main)* en | |
| [1] pry(main)* d | |
| [1] pry(main)> end | |
| SyntaxError: unexpected keyword_end, expecting end-of-input | |
| [1] pry(main)> class MyObject | |
| [1] pry(main)* def my_method(one, two) | |
| [1] pry(main)* one = nil | |
| [1] pry(main)* two = nil | |
| [1] pry(main)* end | |
| [1] pry(main)* end | |
| => :my_method | |
| [2] pry(main)> class MyObject | |
| [2] pry(main)* def initialize(one, two) | |
| [2] pry(main)* @instance = instance | |
| [2] pry(main)* end | |
| [2] pry(main)* end | |
| => :initialize | |
| [3] pry(main)> MyObject.new | |
| ArgumentError: wrong number of arguments (0 for 2) | |
| from (pry):8:in `initialize' | |
| [4] pry(main)> MyObject.new("a", "B") | |
| NameError: undefined local variable or method `instance' for #<MyObject:0x007fefa3838f70> | |
| from (pry):9:in `initialize' | |
| [5] pry(main)> class Node | |
| [5] pry(main)* def initialize(data, link) | |
| [5] pry(main)* # Node.new("pizza", "some other node?") | |
| [5] pry(main)* @data = data | |
| [5] pry(main)* @link = link | |
| [5] pry(main)* end | |
| [5] pry(main)* end | |
| => :initialize | |
| [6] pry(main)> Node.new("this will be data", "this will be link") | |
| => #<Node:0x007fefa10b7c30 | |
| @data="this will be data", | |
| @link="this will be link"> | |
| [7] pry(main)> link | |
| NameError: undefined local variable or method `link' for main:Object | |
| from (pry):22:in `__pry__' | |
| [8] pry(main)> Node.new("this will be data", "this will be link") | |
| => #<Node:0x007fefa3869580 | |
| @data="this will be data", | |
| @link="this will be link"> | |
| [9] pry(main)> node = Node.new("this will be data", "this will be link") | |
| => #<Node:0x007fefa3819d28 | |
| @data="this will be data", | |
| @link="this will be link"> | |
| [10] pry(main)> node.link | |
| NoMethodError: undefined method `link' for #<Node:0x007fefa3819d28> | |
| from (pry):25:in `__pry__' | |
| [11] pry(main)> class Node | |
| [11] pry(main)* def link | |
| [11] pry(main)* @link | |
| [11] pry(main)* end | |
| [11] pry(main)* end | |
| => :link | |
| [12] pry(main)> node.link | |
| => "this will be link" | |
| [13] pry(main)> class Node | |
| [13] pry(main)* def data | |
| [13] pry(main)* @data | |
| [13] pry(main)* end | |
| [13] pry(main)* end | |
| => :data | |
| [14] pry(main)> node.data | |
| => "this will be data" | |
| [15] pry(main)> class LinkedList | |
| [15] pry(main)* def initialize(head, tail) | |
| [15] pry(main)* @head = head | |
| [15] pry(main)* @tail = tail | |
| [15] pry(main)* end | |
| [15] pry(main)* end | |
| => :initialize | |
| [16] pry(main)> LinkedList.new(node) | |
| ArgumentError: wrong number of arguments (1 for 2) | |
| from (pry):39:in `initialize' | |
| [17] pry(main)> LinkedList.new(node, nil) | |
| => #<LinkedList:0x007fefa12a6a28 | |
| @head= | |
| #<Node:0x007fefa3819d28 | |
| @data="this will be data", | |
| @link="this will be link">, | |
| @tail=nil> | |
| [18] pry(main)> LinkedList.new(node, "needs a tail") | |
| => #<LinkedList:0x007fefa1c1d368 | |
| @head= | |
| #<Node:0x007fefa3819d28 | |
| @data="this will be data", | |
| @link="this will be link">, | |
| @tail="needs a tail"> | |
| [19] pry(main)> list = LinkedList.new(node, "needs a tail") | |
| => #<LinkedList:0x007fefa1b6d8f0 | |
| @head= | |
| #<Node:0x007fefa3819d28 | |
| @data="this will be data", | |
| @link="this will be link">, | |
| @tail="needs a tail"> | |
| [20] pry(main)> list.head | |
| NoMethodError: undefined method `head' for #<LinkedList:0x007fefa1b6d8f0> | |
| from (pry):48:in `__pry__' | |
| [21] pry(main)> class LinkedList | |
| [21] pry(main)* def head | |
| [21] pry(main)* @head | |
| [21] pry(main)* end | |
| [21] pry(main)* end | |
| => :head | |
| [22] pry(main)> list.head | |
| => #<Node:0x007fefa3819d28 | |
| @data="this will be data", | |
| @link="this will be link"> | |
| [23] pry(main)> list.head.data | |
| => "this will be data" | |
| [24] pry(main)> list.head.link | |
| => "this will be link" | |
| [25] pry(main)> list.class | |
| => LinkedList | |
| [26] pry(main)> list.head.class | |
| => Node | |
| [27] pry(main)> list.head.class | |
| => Node | |
| [28] pry(main)> list.head.link.class | |
| => String | |
| [29] pry(main)> list.head.link | |
| => "this will be link" | |
| [30] pry(main)> list.head.data | |
| => "this will be data" | |
| [31] pry(main)> list.head.data.class | |
| => String | |
| [32] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment