mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-13 06:43:20 -04:00
Use alt example in about_open_classes
Integer#even? ended up in a more modern version of ruby (yay progress!). This updates the koan to use a different, more outlandish example, that I don’t think will end up in Ruby — and that I know Jim would appreciate <3
This commit is contained in:
@@ -30,14 +30,14 @@ class AboutOpenClasses < Neo::Koan
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
class ::Integer
|
||||
def even?
|
||||
(self % 2) == 0
|
||||
def answer_to_life_universe_and_everything?
|
||||
self == 42
|
||||
end
|
||||
end
|
||||
|
||||
def test_even_existing_built_in_classes_can_be_reopened
|
||||
assert_equal __(false), 1.even?
|
||||
assert_equal __(true), 2.even?
|
||||
assert_equal __(false), 1.answer_to_life_universe_and_everything?
|
||||
assert_equal __(true), 42.answer_to_life_universe_and_everything?
|
||||
end
|
||||
|
||||
# NOTE: To understand why we need the :: before Integer, you need to
|
||||
|
||||
Reference in New Issue
Block a user