From: Dan Zwell Date: 2007-08-24T16:59:18+09:00 Subject: Re: something I just found out, am sharing (:newbish) Axel wrote: > Hello, > >> "*=", "/=", "&&=", "||=", and any others that I may have missed... > > Can anybody tell me, where to find, what this means? > > Thank you! > > Axel > var1 = var2 is always equivalent to var1 = var2 2 For example, num ||= 0 is frequently used to mean "if num is nil, num = 0". The longhand is "num = num || 0", as "num || 0" evaluates to num if num is non-nil, and "0" otherwise. Good for making sure strings or numbers are initialized: my_str ||= "" &&= is good for making sure a group of things are all true: result = true expressions.each {|expr| result &&= expr} The simpler operators are these: a /= b means: a = a/b Same goes for the others: my_str = "hello " my_str *= 3 is the same as: my_str = my_str * 3 I no longer have my list of web sites I learned Ruby from, but it's pretty simple. Hope this helps. Dan