Hi, If you are using the trunk (not 2.1.0), then you can compare any two numerical types (but adding them is not currently allowed, but should be allowed soon. follow: http://jira.codehaus.org/browse/XTENLANG-2075)
public struct Int implements Comparable[Int] /*TODO implements Arithmetic[Int], Bitwise[Int], Ordered[Int]*/ { class Test { def compare[T](x:T,y:T) { T <: Comparable[T] } = x.compareTo(y); def add[T](x:T,y:T) { T <: Arithmetic[T] } = x+y; def test() { var x:Int=2, y:Int=3; use(compare(x,y)); // ok use(add(x,y)); // cause an ERROR because Int still doesn't implement Arithmetic } } On Fri, Dec 3, 2010 at 1:04 PM, LEONID ILYEVSKY <leonidilyev...@yahoo.com>wrote: > I wonder if in x10 I can do something like this: > > Write a generic method that takes two arguments x and y, both of the same > numerical type (i.e. both Int, or both Double, etc.), and returns their sum > x+y > as a value of the proper type. > I know this can easily be done in Java > > ------------------------------------------------------------------------------ > What happens now with your Lotus Notes apps - do you make another costly > upgrade, or settle for being marooned without product support? Time to move > off Lotus Notes and onto the cloud with Force.com, apps are easier to > build, > use, and manage than apps on traditional platforms. Sign up for the Lotus > Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d > _______________________________________________ > X10-users mailing list > X10-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/x10-users > ------------------------------------------------------------------------------ What happens now with your Lotus Notes apps - do you make another costly upgrade, or settle for being marooned without product support? Time to move off Lotus Notes and onto the cloud with Force.com, apps are easier to build, use, and manage than apps on traditional platforms. Sign up for the Lotus Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users