Last active
December 19, 2015 06:39
-
-
Save kyrylo/5913204 to your computer and use it in GitHub Desktop.
Ruby for entertainment #1
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
| [1] pry(main)> HELLO!!! | |
| | def answer | |
| | :HI! | |
| | end | |
| NoMethodError: undefined method `HELLO!' for main:Object | |
| from (pry):4:in `__pry__' | |
| [2] pry(main)> answer | |
| => :"HI!" |
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
| [2] pry(main)> HELLO!!! | |
| | [1, 2, 3].map { |n| | |
| | HI!!! | |
| | n + 100 | |
| | } | |
| NoMethodError: undefined method `+' for true:TrueClass | |
| from (pry):9:in `block in __pry__' |
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(main)> HELLO!!! | |
| | [1, 2, 3].map { |n| | |
| | HI!!! | |
| | n += 100 | |
| | } | |
| NoMethodError: undefined method `HI!' for main:Object | |
| from (pry):14:in `block in __pry__' |
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
| [1] pry(main)> CLASSY!!! | |
| | class A | |
| | AWESOME!!! | |
| | class B | |
| | MARVELOUS!!! | |
| | def great | |
| | 'awful :-(' | |
| | end | |
| | end | |
| | end | |
| NoMethodError: undefined method `MARVELOUS!' for A::B:Class | |
| from (pry):7:in `<class:B>' | |
| [2] pry(main)> A | |
| => A | |
| [3] pry(main)> A::B | |
| => A::B | |
| [4] pry(main)> A::B.new.great | |
| => "awful :-(" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment