Skip to content

Instantly share code, notes, and snippets.

@maizy
Created June 1, 2015 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maizy/c1839bd6d235cc656349 to your computer and use it in GitHub Desktop.
Save maizy/c1839bd6d235cc656349 to your computer and use it in GitHub Desktop.
Anonymous func from method with implicit params?
$ scala
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_67).
Type in expressions to have them evaluated.
Type :help for more information.
scala> class MyContext2(val m: Int)
defined class MyContext2
scala> object TestObj2{ def withImp(s: String)(implicit c: MyContext2): String = s"c:${c.m}" }
defined object TestObj2
scala> val func = TestObj2.withImp _
<console>:9: error: could not find implicit value for parameter c: MyContext2
val func = TestObj2.withImp _
^
@maizy
Copy link
Author

maizy commented Jun 1, 2015

Пока придумал только

val simpleSolution = (s: String, c: MyContext2) => TestObj2.withImp(s)(c)

но хочется оставить анонимный метод с implicit параметром. хотя кажется это не возможно.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment