Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created February 27, 2010 01:28
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 jutememo/316379 to your computer and use it in GitHub Desktop.
Save jutememo/316379 to your computer and use it in GitHub Desktop.
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