From: Hugh Sasse Staff Elec Eng Date: 2000-11-09T04:56:00+09:00 Subject: [ruby-talk:6177] Re: detect:ifNone: in Ruby On Thu, 9 Nov 2000, [iso-8859-1] Aleksi Niemel� wrote: > matju writes: > > a .when_nil { b } > > This sounds like good name. How about generalizing a little and having > > module Kernel > def when(value, default=nil) > if self == value > if iterator? > yield > else > default > end > else > self > end > end > end > So I'd have print myarray.sort!.when(nil,myarray).uniq!.when(nil,myarray).inspect you mean? Hugh