From: Jeremy Evans Date: 2009-09-30T00:10:29+09:00 Subject: Re: Sequel accessor methods Jake Brightmatter wrote: >> def new_house( self_id ) >> DataBase[:house].insert(:id => self_id) unless DataBase[:house][:id >> => self_id] >> end > > I don't suppose you could explain that syntax could you... what exactly > are you doing? Sure thing: DataBase[:house][:id => self_id] This will return the first row in the database where the id column matches self_id (as a hash), or nil if no item matches. Since you only want to insert the row if there isn't an existing row with the id, if it returns anything except nil, you don't call insert. DataBase[:house].insert(:id => self_id) This inserts the row with the id column set to self_id. Jeremy -- Posted via http://www.ruby-forum.com/.