Skip to content

Instantly share code, notes, and snippets.

@pedrofurla
Created October 8, 2017 01:53
Show Gist options
  • Save pedrofurla/949a20cbf308c2185210840230ec7f76 to your computer and use it in GitHub Desktop.
Save pedrofurla/949a20cbf308c2185210840230ec7f76 to your computer and use it in GitHub Desktop.
scala> :paste
// Entering paste mode (ctrl-D to finish)
class A[T] {
def add(n: Int)( env: T =:= Int = null): Boolean = if(env == null) true else false
}
val a = new A[Int]
a.add(1) // 2
// Exiting paste mode, now interpreting.
<pastie>:18: error: missing argument list for method add in class A
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `add _` or `add(_)(_)` instead of `add`.
a.add(1) // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment