If anyone is learning Ruby, and wants to become more familiar with various nuances, go download the Ruby Koans.
There are about two dozen files, each discussing a specific topic. You go through each file, looking for __
segments and replace them with statements which would result in true
assertions.
After completing a few, you can run ruby path_to_enlightenment.rb and you get the following prompt:
user:~/koans$ ruby path_to_enlightenment.rb AboutNil#test_nil_is_an_object has expanded your awareness. AboutNil#test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil has expanded your awareness. AboutNil#test_nil_has_a_few_methods_defined_on_it has expanded your awareness. AboutObjects#test_everything_is_an_object has damaged your karma. The Master says: You have not yet reached enlightenment. You are progressing. Excellent. 8 completed. The answers you seek... <"FILL ME IN"> expected but was <true>. Please meditate on the following code: /home/alex/local/ruby/koans/about_objects.rb:5:in `test_everything_is_an_object' when you lose, don't lose the lesson your path thus far [.X________________________________________________] 8/280 user:~/koans$
This really helps understand some of the nuances underpinning Ruby.
No comments:
Post a Comment