From: Gregory Millam Date: 2004-06-05T03:48:07+09:00 Subject: Re: Check assertion in Ruby Received: Sat, 5 Jun 2004 03:34:47 +0900 And lo, Edgardo wrote: > Hi, everybody. I would like to use an assert like function to test the > number of rows returned by a query. Something like Eiffel's > > check result.num_rows = 1 > > What's the best way to do that in Ruby? > result.num_rows == 1 or raise "num_rows is not 1" is equivalent to raise "num_rows is not 1" unless result.num_rows == 1 The 'or/and' method is idiomatic, while the 'if/unless' is more readable. - Greg