Skip to content

Instantly share code, notes, and snippets.

@sudowork
Last active December 12, 2015 10:39
Show Gist options
  • Save sudowork/4760760 to your computer and use it in GitHub Desktop.
Save sudowork/4760760 to your computer and use it in GitHub Desktop.
scala> "foo" + 4
res0: String = foo4
scala> 4 + "foo"
res1: String = 4foo
scala> 4 + "2.0"
res2: String = 42.0
scala> 2 * "21"
<console>:8: error: overloaded method value * with alternatives:
(x: Double)Double <and>
(x: Float)Float <and>
(x: Long)Long <and>
(x: Int)Int <and>
(x: Char)Int <and>
(x: Short)Int <and>
(x: Byte)Int
cannot be applied to (String)
2 * "21"
^
scala> // Stuff to come
scala> implicit def string2int(s: String) = s.toInt
string2int: (s: String)Int
scala> 2 * "21"
res3: Int = 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment