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

this is equally untrue true for strings, of course.

  “foo”+”bar” != “bar” + “foo”
there are valid non-commutative additions.


An interesting example is C's pointer-integer addition. p + n == n + p, true, but this is a purely syntactic fact. The actual semantic question of commutativity, whether switching the order of the arguments leaves the value unchanged, cannot even be asked of pointer-integer addition since the arguments, having differing types, cannot be switched.


Indeed in C even array[index] is equivalent to index[array], just in case you want to be confusing.


and is also a good reason to use a different operator for it too such as & or. and even space in some languages.


in the specific case of strings, my preferred way to spell that in python is

  f”{'foo'}{'bar'}”




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

Search: