From: Sharad Gupta Date: 2007-03-15T23:57:04+09:00 Subject: Re: What does this do? : ------=_Part_39686_19124064.1173970623361 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline You have to see the statement in its entirety. Its centered around the ternary operator ?: What the code is doing is: if (user.id == recipient_id) { sender } else { recipient } On 3/15/07, jko170 wrote: > > Looking at this piece of code, what does the colon do? > > def partner_to(user) > raise ArgumentError unless user > user.id == recipient_id ? sender : recipient > end > > I got the code from this rails post: > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/7fdccddde9b97ffc/6112294580b9e0ce?lnk=gst&q=internal+mail&rnum=1#6112294580b9e0ce > > I'm just asking because I've never seen the colon used before. > > > ------=_Part_39686_19124064.1173970623361--