I had a look at Acme::Don't while I was there, and it looks like an interesting poor person's multiline comment (but remember, commenting out code is bad mmmkay?)
Andrew On Tue, Mar 10, 2009 at 4:35 PM, Julio Cesar Ody <[email protected]> wrote: > > When I saw that class declaration getting a condition right at the > end, there's one thing that came to my mind: > > http://search.cpan.org/~pjf/Acme-ButFirst-1.00/lib/Acme/ButFirst.pm<http://search.cpan.org/%7Epjf/Acme-ButFirst-1.00/lib/Acme/ButFirst.pm> > > > > > On Tue, Mar 10, 2009 at 4:31 PM, Cameron Barrie > <[email protected]> wrote: > > conditionals on the end of lines. simple but awesome. > > puts "Awesome" if @apple.awesome? > > rather than the verbose and less readable C example :P > > if (apple->flavour == "awesome") > > printf("Awesome\n"); > > You can even use them on the ends of class definitions and such if really > > want to. > > class Foo > > end if defined?(Foo).nil? > > > > C > > > > > > > > On 10/03/2009, at 4:15 PM, Daniel N wrote: > > > > > > On Tue, Mar 10, 2009 at 4:05 PM, Clifford Heath < > [email protected]> > > wrote: > >> > >> On 10/03/2009, at 3:52 PM, Nick Partridge wrote: > >> > Symbol-to-proc, and the use of `&` to coerce things to procs: > >> > > >> > [1,2,3,4,5].select(&:odd?) > >> > > >> > Awww yeah. > >> > >> Cute but wasteful, and now deprecated in all Rails core code because of > >> the extra (non-gc-able?) object it creates. > >> > >> I like this for creating and adding to hash values consisting of an > >> array: > >> > >> things_by_key = {} > >> things.each do |thing| > >> (things_by_key[thing.key] ||= []) << thing > >> end > >> > >> or the same using inject... > >> > >> Clifford Heath. > >> > > > > Hey Cliff, > > > > One of the things I like with hashes is default values set with procs :) > > > > things_by_key = Hash.new{|h,k| h[k] = []} > > things.each do |thing| > > things_by_key[thing.key] << thing > > end > > > > I use these all the time for default values in all sorts of ways :) > > > > Daniel > > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~---
