Created
February 27, 2010 01:28
-
-
Save jutememo/316379 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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