Created
December 2, 2011 13:19
-
-
Save halcat0x15a/1423217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class ScalaChan() | |
| implicit def ScalaChanEqual: Equal[ScalaChan] = new Equal[ScalaChan] { | |
| def equal(a1: ScalaChan, a2: ScalaChan): Boolean = a1 == a2 | |
| } | |
| implicit def ScalaChanEqual: Equal[ScalaChan] = equal(_ == _) | |
| implicit def ScalaChanEqual: Equal[ScalaChan] = equalA | |
| assert(ScalaChan() === ScalaChan()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> 1 === 1 | |
| res39: Boolean = true | |
| scala> 1 /== 1 | |
| res41: Boolean = false | |
| scala> 1 /== 1L | |
| <console>:23: error: type mismatch; | |
| found : Long(1L) | |
| required: Int | |
| 1 /== 1L | |
| ^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| assert("Scalaz" ≟ "Scalaz") | |
| assert("Scalaちゃん" ≠ "Scalaz") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> "Scalaz" assert_=== "Scalaz" | |
| scala> "Scalaちゃん" assert_=== "Scalaz" | |
| java.lang.RuntimeException: Scalaちゃん ≠ Scalaz | |
| at scalaz.Scalaz$.error_(Scalaz.scala:100) | |
| at scalaz.Identity$class.assert_$eq$eq$eq(Identity.scala:32) | |
| at scalaz.Identity$$anon$1.assert_$eq$eq$eq(Identity.scala:169) | |
| . | |
| . | |
| . | |
| . | |
| scala> "Scalaちゃん" assert_≟ "Scalaちゃん" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val i: Identity[Int] = 1 | |
| val a: Int = i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "Scalaz" ?? "Scalaちゃん" assert_=== "Scalaz" | |
| (null: String) ?? "Scalaちゃん" assert_=== "Scalaちゃん" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 |> (_ + 1) assert_=== 2 | |
| 1 |> Option.apply assert_=== Some(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.some assert_=== Some(1) | |
| 1.right[String] assert_=== Right(1) | |
| "Scalaちゃん".left[Int] assert_=== Left("Scalaちゃん") | |
| "ゲソ".pair.assert_===(("ゲソ", "ゲソ")) | |
| "ゲソ".pair assert_=== "ゲソ".squared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.whileDo(_ + 1, _ < 10) assert_=== 10 | |
| "Scala".doWhile({ s => println(s); readLine }, _ != "Scalaz") assert_=== "Scalaz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment