News for hackers. Stuff that matters.
Re:What's better about Ruby than Python? - comp.lang.python by ominous_prime on Thursday August 26, 2010 @11:05PM (#1637898)
In python the convention tends to be:

  a.inverse() -> mutates 'a' to its inverse
  MatrixMath.inverse(a) -> returns the inverse of 'a', leaving 'a' unchanged
Re:What's better about Ruby than Python? - comp.lang.python by xtho on Friday August 27, 2010 @05:44AM (#1638370)
1 isn't a matrix. Integers/floating point numbers are in many languages treated differently than other types for reasons of performance and memory management etc. Ruby isn't different in this respect (IIRC they call it immediate objects). A matrix is a "normal" object in ruby.

BTW the ruby equivalent for the above convention would be (maybe inspired by scheme?)

    a.inverse!() -> mutate a
    a.inverse() -> return the inverse
Which one is more consistent?
Re:What's better about Ruby than Python? - comp.lang.python by rikthevik on Friday August 27, 2010 @01:52PM (#1639533)
I am a python user, but I _really_ like that .inverse!() notation indicating that the object itself is being mutated. It's concise and consistent. Sometimes punctuation in names is exactly what you need. Same with ? for predicates. I'll take even? over evenp any day of the week.
Re:What's better about Ruby than Python? - comp.lang.python by Confusion on Friday August 27, 2010 @10:50AM (#1638967)

  1 isn't a matrix
A Fixnum could be interpreted as a 1x1 matrix. For some recursive solutions, it would probably be nice of MatrixMath.inverse accepted it as such, as well as [[1]].
Re:What's better about Ruby than Python? - comp.lang.python by aphyr on Friday August 27, 2010 @03:29PM (#1639919)
This confuses me, because python strings use str.lower() to return a lowercase copy of str, leaving str unchanged. I prefer the Ruby idiom of naming the mutating versions with a !.