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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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