Hacker Newsnew | past | comments | ask | show | jobs | submit | wub's commentslogin

> They put the arrow where it was increased for a short duration, but then immediately after this the temperature is lowered considerably.

I don't think ~80 miles could be considered a "short duration".


I can't help but feel that even the "good" example makes things unnecessarily complicated for the sake of saving one line of code.

    # original
    start_date, end_date = ["24 Dec 2011", "23 Jan 2013"].map {|d| Date.parse(d) }

    # better
    start = Date.parse("24 Dec 2011")
    end = Date.parse("23 Jan 2013")


This really depends. If your data already comes in tupels (which often happens in this case), deconstructing assignment can express very well what you are doing.

    # original
    start_date, end_date = timeframe.map { |d| Date.parse(d) }

    # better?
    start_date = Date.parse(timeframe[0])
    end_date = Date.parse(timeframe[1])
For decent Rubyists, reading a map is very easy. On the other hand, both versions are acceptable - I wouldn't bother discussing about either of the options.


Quite probably. I suck at making up "good" examples without taking them from code - couldn't think of anything suitable to borrow from last night.

I think my thought process was reading a CSV from stdin with two fields, using String#split instead of the CSV library and ending up with an array with two elements. That would've complicated it even more though. :-)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: