From: Vincent Fourmond Date: 2006-10-22T06:33:52+09:00 Subject: Re: Conditional modifier syntax Pau Garcia i Quiles wrote: > Hello, > > Am I the only one who finds beautiful this syntax for conditional modifiers? > > @playlist= source[:playlist] if source[:playlist].instance_of?(XSPF::Playlist) > else raise TypeError "The playlist must be an instance of XSPF::Playlist" > > PS: It's beautiful but it doesn't work :-/ Well, you can use if in two different ways: a if b or if a b end Only in the second case you can use else. I would write it this way: (in two lines, in case that doesn't show in the mail) raise TypeError "The playlist must be an instance of XSPF::Playlist" unless source[:playlist].instance_of?(XSPF::Playlist) @playlist= source[:playlist] I tend to find that more clear: you first leave out the case that doesn't interest you. Just my opinion ;-) ! Vince