Skip to content

Instantly share code, notes, and snippets.

@kkismd
Created July 8, 2015 10:42
Show Gist options
  • Save kkismd/aa20046aa52c8e81b267 to your computer and use it in GitHub Desktop.
Save kkismd/aa20046aa52c8e81b267 to your computer and use it in GitHub Desktop.
パーシャルファンクション
import scala.Function2;
import scala.Predef.;
import scala.Serializable;
import scala.runtime.AbstractFunction2;
import scala.runtime.BoxesRunTime;
public final class Main$
{
public static final MODULE$;
static
{
new ();
}
public void main(String[] args)
{
Predef..MODULE$.println(
BoxesRunTime.boxToBoolean(
test(new AbstractFunction2() {
public static final long serialVersionUID = 0L;
public final boolean apply(String x$1, String x$2) { return x$1.endsWith(x$2); }
}
)
)
);
}
public boolean test(Function2<String, String, Object> f) { return BoxesRunTime.unboxToBoolean(f.apply("foo", "o")); }
private Main$() { MODULE$ = this; }
}
object Main {
def main(args: Array[String]): Unit = {
println(test(_.endsWith(_)))
}
def test(f: (String,String) => Boolean): Boolean = f("foo", "o")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment