| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.8 - 28 Apr 2005 - TWikiGuest) |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.7 - 29 Jan 2005 - LiYan) |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.6 - 25 Jan 2005 - LiYan) |
| Added: | |
| > > | 展示架 生物反应器 笔记本电脑 成人用品 翻译 鲜花 移民 翻译公司 租房 游戏 游戏下载 摸屏 壁纸 服务器 爱滋病 办公自动化 出国 短信 干燥设备 交友 聊天 门禁 内衣 升降机 视频 写真 仪器仪表 移动存储 音乐 自考 算命 惠普 诺基亚 体育彩票 网页制作 前列腺 索尼 宠物 大连 电力 福利彩票 个人主页 广告公司 国际贸易 会计 计算机等级考试 交通 宽带 免费空间 农业 企业文化 人才 人才网 设计 手机报价 图书 网络 网络游戏 物业管理 西门子 小灵通 幼儿教育 幼儿园 娱乐 注册会计师 财务 财务管理 出国留学 电脑培训 多媒体 翻译软件 飞机票 购物 管理 婚纱摄影 激光 计算机培训 空间 律师 律师事务所 贸易 美容美发 模型 纳米 商标 数据库 通讯 网络安全 项目管理 鞋 雅思 英语培训 园林 招标 纸 中医 |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.5 - 29 Dec 2004 - ArjanB) |
| Deleted: | |
| < < | |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.4 - 07 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | /* Please try the NoviceExamples? before the BeginnerExamples? |
| > > | /* Please try the NoviceExamples? before these examples |
| Changed: | |
| < < | /* Please try the NoviceExamples? before the BeginnerExamples? |
| > > | /* Please try the NoviceExamples? before these examples |
| Changed: | |
| < < | /* Please try the NoviceExamples? before the BeginnerExamples? |
| > > | /* Please try the NoviceExamples? before these examples |
| Changed: | |
| < < | %META:TOPICMOVED{by="IsaacGouy" date="1076120572" from="Doc.NumberFiveBeginnerExample" to="Doc.NumberFiveTypeParameterExample"}% |
| > > | %META:TOPICMOVED{by="IsaacGouy" date="1076169836" from="Doc.NumberFiveTypeParameterExample" to="Doc.NumberFiveParametricTypeExample"}% |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.3 - 07 Feb 2004 - IsaacGouy) |
| Added: | |
| > > | %META:TOPICMOVED{by="IsaacGouy" date="1076120572" from="Doc.NumberFiveBeginnerExample" to="Doc.NumberFiveTypeParameterExample"}% |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.2 - 11 Oct 2003 - IsaacGouy) |
| Changed: | |
| < < | < T | T <: double, int <: T > T numberFive() = 5; |
| > > | < T | T <: double, int <: T > T numberFive(){ return 5; } |
| Added: | |
| > > | T numberFive(){ return 5; } numberFive() returns a value of type T |
| Changed: | |
| < < | < T | T <: double, int <: T > T numberFive() = long(5); |
| > > | < T | T <: double, int <: T > T numberFive(){ return long(5); } |
| Changed: | |
| < < | T numberFive() = long(5); |
| > > | T numberFive(){ return long(5); } |
| Changed: | |
| < < |
|
| > > |
|
| Changed: | |
| < < | < T | T <: double, long <: T > T numberFive() = long(5); |
| > > | < T | T <: double, long <: T > T numberFive(){ return long(5); } |
| Changed: | |
| < < | T numberFive() = long(5); |
| > > | T numberFive(){ return long(5); } |
| <<O>> Difference Topic NumberFiveParametricTypeExample (r1.1 - 11 Oct 2003 - IsaacGouy) |
| Added: | |
| > > |
%META:TOPICINFO{author="IsaacGouy" date="1065886680" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="CodeExamples"}%
/* Please try the NoviceExamples before the BeginnerExamples
To compile:
nicec --sourcepath=.. -a numberfive.jar numberfive
*/
< T | T <: double, int <: T >
T numberFive() = 5;
void main(String[] args){
int a = numberFive();
println( a.getClass.getName + " " + a);
long b = numberFive();
println( b.getClass.getName + " " + b);
float c = numberFive();
println( c.getClass.getName + " " + c);
double d = numberFive();
println( d.getClass.getName + " " + d + '\n');
let e = numberFive();
println( e.getClass.getName + " " + e);
}
/* Notes - language
< T | T <: double, int <: T >
Any type T, where T is a subtype of primitive type double
and T is type int or above.
Nice\test>java -jar t.jar
java.lang.Integer 5
java.lang.Long 5
java.lang.Float 5.0
java.lang.Double 5.0
java.lang.Integer 5
*/
/* Please try the NoviceExamples before the BeginnerExamples
To compile:
nicec --sourcepath=.. -a numberfive.jar numberfive
*/
< T | T <: double, int <: T >
T numberFive() = long(5);
void main(String[] args){
int a = numberFive();
println( a.getClass.getName + " " + a);
long b = numberFive();
println( b.getClass.getName + " " + b);
float c = numberFive();
println( c.getClass.getName + " " + c);
double d = numberFive();
println( d.getClass.getName + " " + d + '\n');
let e = numberFive();
println( e.getClass.getName + " " + e);
}
/* Notes - language
< T | T <: double, int <: T >
Any type T, where T is a subtype of primitive type double
and T is type int or above.
T numberFive() = long(5);
Cast 5 to primitive type long
Nice\test\..\test\test.nice: line 7, column 18:
Incorrect return type:
Found : nice.lang.long
Expected: T
T the return type of numberFive is defined to include primitive
type int - and long to int coercion is required to be explicit
because it may result in data loss - so, because T includes type
int, long(5) does not match the return type T.
*/
/* Please try the NoviceExamples before the BeginnerExamples
To compile:
nicec --sourcepath=.. -a numberfive.jar numberfive
*/
< T | T <: double, long <: T >
T numberFive() = long(5);
void main(String[] args){
long b = numberFive();
println( b.getClass.getName + " " + b);
float c = numberFive();
println( c.getClass.getName + " " + c);
double d = numberFive();
println( d.getClass.getName + " " + d + '\n');
let e = numberFive();
println( e.getClass.getName + " " + e);
}
/* Notes - language
< T | T <: double, long <: T >
Any type T, where T is a subtype of primitive type double
and T is type long or above.
T numberFive() = long(5);
Cast 5 to primitive type long
Nice\test>java -jar t.jar
java.lang.Long 5
java.lang.Float 5.0
java.lang.Double 5.0
java.lang.Long 5
*/
-- IsaacGouy - 11 Oct 2003 |
| Topic NumberFiveParametricTypeExample . { View | Diffs | r1.8 | > | r1.7 | > | r1.6 | More } |
|
Revision r1.1 - 11 Oct 2003 - 15:38 GMT - IsaacGouy Revision r1.8 - 28 Apr 2005 - 11:54 GMT - TWikiGuest |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |