[Note: parts of this message were removed to make it a legal post.]
Yes it's true, you're suppose to fix the code and/or test, but only if it
has a '__' or a comment indicating to fix something. In this case, however,
it's asking what the method will return if the method was called with and
without arguments. Here's the test:
class MessageCatcher
def add_a_payload(*args)
return :empty unless args
args
end
end
def test_sending_a_message_with_arguments
mc = MessageCatcher.new
assert_equal __, mc.add_a_payload
assert_equal __, mc.send
add_a_payload)
assert_equal __, mc.add_a_payload(3, 4, nil, 6)
assert_equal __, mc.send
add_a_payload, 3, 4, nil, 6)
end
The return statement will never return :empty in the asserts. This is what
confused me. I wanted to know when the method will ever return :empty. The
test doesn't test that...because it will never return it ;-)
skim
On Wed, Mar 31, 2010 at 09:07, Gennady Bystritsky <
Wasn't that the idea behind "koans"? I haven't heard about them until
your post, however according to
http://brandon.dimcheff.com/2009/02/05/how-to-learn-ruby.html:
Darn, looks like ":" becomes the part of URL when you click the above link.
Try just this:
http://brandon.dimcheff.com/2009/02/05/how-to-learn-ruby.html
"... The Koans are essentially a series of failing test cases that you
need to figure out how to fix in order to move on to the next step."
From that, my understanding is that a user is supposed to find problems
in "koans" and fix them. You found one, good going ;-)
Regards,
Gennady.
Cheers,
skim
Aldric Giacomoni wrote:
Steve Kim wrote:
Is it possible to have this method return :empty?
class MessageCatcher
def add_a_payload *args
args.empty? :empty : args
end
end
args.empty? [:empty] : args
I'd appreciate it if no one mentioned that I forgot the '?' twice! I am
so ashamed.
args.empty? ? :empty : args
args.empty? ? [:empty] : args