Last active
February 3, 2026 20:25
-
-
Save dacr/0804e5a3dac66fdafcfca0061beab76f to your computer and use it in GitHub Desktop.
lambdas variations in scala / published by https://github.com/dacr/code-examples-manager #4664cc4a-aa71-430c-ab64-76f33effa7b5/b82bb2ffe8919db9fd5c78b59ec867cb322a2faf
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
| // summary : lambdas variations in scala | |
| // keywords : scala, language-feature, fold, @testable | |
| // publish : gist | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 4664cc4a-aa71-430c-ab64-76f33effa7b5 | |
| // created-on : 2021-10-16T10:54:03+02:00 | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file | |
| // --------------------- | |
| //> using scala "3.4.2" | |
| //> using dep "org.scalatest::scalatest:3.2.16" | |
| //> using objectWrapper | |
| // --------------------- | |
| import org.scalatest._, flatspec._, matchers._, OptionValues._ | |
| class ThatSpec extends AnyFlatSpec with should.Matchers { | |
| override def suiteName = "ThatSpec" | |
| "identify function" should "do nothing" in { | |
| Some(true).map(identity) shouldBe Some(true) | |
| Some(false).map(identity) shouldBe Some(false) | |
| } | |
| "magic function placeholder" should "be usable in many situations" in { | |
| Some(true).filter(if (_) false else true) shouldBe None | |
| } | |
| } | |
| org.scalatest.tools.Runner.main(Array("-oDF", "-s", classOf[ThatSpec].getName)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment