Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class Box<A> {
private A contents;
Box(A contents) {
this.contents = contents;
}
/**
* 中身を取り出す
* @return 中身
*/
A takeOut() {
return this.contents;
}
/**
* 中身を加工して取り出す
* @param f 加工するための関数
* @param b 加工するときに使う値
* @return 加工された中身
*/
<B> B takeOut(IBinaryOp<A, B> f, B b) {
return f.apply(this.contents, b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment