snippets / evaluate

Language: Java - First posted by kritzikratzi on 2008-04-28 12:21 (6 months, 3 weeks)
Link to the snippet: http://www.friendsnippets.org/snippet/263/

evaluate for add...

 1 	public T evaluate(){
2 T lValue = left.evaluate();
3 T rValue = right.evaluate();
4
5 if( lValue instanceof Integer ){
6 return (T)(
7 new Integer(
8 ((Integer)lValue).intValue() +
9 ((Integer)rValue).intValue()
10 )
11 );
12 }
13 else{
14 // andere typen...
15 return null;
16 }
17 }
In order to post a comment, you should have a friendsnippet account. Please sign-in.

0 comments

Apr '08

Common Tags



snippet History

Apr '08