Hey guys,
I just whipped up a tiny patch to add first and last back onto OrderedHash (lost in the move from subclass of Array to subclass of Hash) and hoped I could get some +1s / feedback.
Cheers, jb
Hey guys,
I just whipped up a tiny patch to add first and last back onto OrderedHash (lost in the move from subclass of Array to subclass of Hash) and hoped I could get some +1s / feedback.
Cheers, jb
This was more an accident than a feature. How do you use it?
jeremy
Oh, just as shorthand: often to handle something like a default cagegory.
Code would often look something like this (contrived made-up example):
@item_by_category = Post.all.group_by(&:category)
@expanded_posts = params[:expanded] ? @item_by_category[params [:expanded]] : @item_by_category.first
I could have re-written our code but I've always liked the first/last methods so I wrote the patch
Cheers, jb
Just a side note... if you're wanting a default for the hash you could use the Hash#default= and Hash#default methods.