+: is strange

Isn't this strange?

Array(1, 2) +: "hello"
=> scala.collection.immutable.IndexedSeq[Any] = Vector(Array(1, 2), h,
e, l, l, o)

Array(1, 2).+:("hello")
=> Array[Any] = Array(hello, 1, 2)

"hello" +: Array(1, 2)
=> Array[Any] = Array(hello, 1, 2)

"hello".+:(Array(1, 2))
=> scala.collection.immutable.IndexedSeq[Any] = Vector(Array(1, 2), h,
e, l, l, o)

Re: Re: +: is strange

For eithers, that one helps:
implicit def throwable2Either[T >: Throwable](t: T) = new {  def <->[V](v: V): T Either V = {    Option(t).map(Left(_)).getOrElse(Right(v))   }}
var t = new Exceptiont <-> null
t = nullt <-> 3
On Tue, Jun 21, 2011 at 11:07 AM, Tony Morris <tonymorris [at] gmail [dot] com> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 21/06/11 20:56, Kevin Wright wrote:
> It's also worth noting that these operations come in pairs, so a :+
> b is the same as a.:+(b)
>
> This gives a very nice symmetry.

My favourite is adding a binary map on binary covariant functors:

f <-: either :-> g
f <-: tuple2 :-> g

e.g.

scala> val j = ("boobs" + _) <-: ("abc", 9) :-> (88+)
j: (java.lang.String, Int) = (boobsabc,97)

- --
Tony Morris
http://tmorris.net/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4ApYQACgkQmnpgrYe6r61ePgCfTjMoDwG1Kcso6t/NhSXSWV2F
J+UAoKxxuVshRPyUYxsWl43wGJfhiO+d
=6KxE
-----END PGP SIGNATURE-----

--
Lucas B. Torri