Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The C code for Fixnum#to_f is quite literally

  fix_to_f(VALUE num) {
    double val;
    val = (double)FIX2LONG(num); //RSHIFTs sign
    return DBL2NUM(val); //Ruby float constructor of C double value
  }
It does the same thing. Ruby, by design, flows left to right instead of nested params. This way you don't have float(user.timestamp) but instead user.timestamp.to_f.


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

Search: