Hacker News new | past | comments | ask | show | jobs | submit login

> By avoiding things like implicit ...

Implicit parameters are nothing more than a terminal argument list which the compiler attempts to provide from "the implicit scope." If you would rather it not, then simply provide them yourself at the point of invocation.

To wit:

  object HitchhikersGuide
  {
    implicit val answer : Int = 42;
    implicit val question : String = "the universe";

    def foo ()
      (implicit a : Int, q : String)
      : Unit =
      System.out.println (s"${q} = ${a}");

    // This
    foo ();

    // Is the same as this
    foo () (42, "the universe");
  }
It is left as an exercise for the reader to verify (hint: javap[0] is your friend).

HTH

0 - https://docs.oracle.com/javase/7/docs/technotes/tools/window...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: