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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -