Hello there.
I want to know about how to write a top-level function with generics.
I want to my library provide about type-safe test case.
for example.
expect("foobar").toBe(777); // error on compile-time. String is not int.
now, I wrote a this code.
Expection expect(var obj){
return new _ExpectionImpl.expect(obj);
}
However, I want to write like this!
Expection<T> expect(T obj){
return new _ExpectionImpl.expect(obj);
}
expect("hoge").toBe("hoge");
↑ return 'Expection<String>' type.
but I can't done it.
Do you know a some solutions? I need a some advice.
real code is here.
regards.