In ruby, nil is considered falsey in a boolean context.
The expression nil || 0 behaves like false || 0.
Since The || operator "short-circuits", if @size has a value other than false or nil, it will stop evaluating the expression and return @size. But if it's nil or false, it will continue evaluating it and return 0.
The "Random Tests" section doesn't work correctly for Ruby.
Testingfor {"saiyajin invasion"=>-38}
Itshouldworkforrandominputstoo-Expected:"It took 252 licks to get to the tootsie roll center of a tootsie pop.",
insteadgot:"It took 214 licks to get to the tootsie roll center of a tootsie pop."
It adds the positive values from env but doesn't subtract the negative ones.
It shouldn't be possible to require
active_support
in my opinion. It's not in the standard library.Indeed doing it in-place causes the tests to fail for me.
The description should really mention this.
In ruby,
nil
is considered falsey in a boolean context.The expression
nil || 0
behaves likefalse || 0
.Since The
||
operator "short-circuits", if @size has a value other thanfalse
ornil
, it will stop evaluating the expression and return @size. But if it'snil
orfalse
, it will continue evaluating it and return0
.I hope that makes sense!
This comment is hidden because it contains spoiler information about the solution
The "Random Tests" section doesn't work correctly for Ruby.
It adds the positive values from
env
but doesn't subtract the negative ones.My solution passes all the Basic Tests.
This comment is hidden because it contains spoiler information about the solution
Note: this only works because of a lack of test coverage
"abe" is greater than "abcd", but also shorter.