Ruby: toggle a boolean inline? -
how can opposite of boolean in ruby (i know converted 0/1) using method inline?
say have given instance:
class vote def return_opposite self.value end end
which doesn't anything, can't seem find method simple , short opposite()
or like. exist , i'm not looking @ right place in docs? if 1 doesn't exist there short ternary toggle 1 => 0 or 0 => 1?
i use
@object.boolean = !@object.boolean
Comments
Post a Comment