05_developer_tutorials:dev-guide:automatic-conversion
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| 05_developer_tutorials:dev-guide:automatic-conversion [2025/02/19 15:51] – removed - external edit (Unknown date) 127.0.0.1 | 05_developer_tutorials:dev-guide:automatic-conversion [2025/02/19 15:51] (current) – ↷ Page moved from 04_developer_documentation:dev-guide:automatic-conversion to 05_developer_tutorials:dev-guide:automatic-conversion gaetan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Implicit conversion ====== | ||
| + | |||
| + | GroIMP compiler can automatically perform implicit conversions. | ||
| + | By default RGG files use this implicit conversions. A common example is the conversion from float to double (and vice versa). | ||
| + | |||
| + | |||
| + | ==== Add a conversion ==== | ||
| + | |||
| + | During compilation, | ||
| + | |||
| + | |||
| + | ==== Example ==== | ||
| + | |||
| + | This is a working piece of code in RGG, that cannot compile in java: | ||
| + | |||
| + | <code java> | ||
| + | class Test1 {} | ||
| + | |||
| + | class Test2 { | ||
| + | static Test2 valueOf(Test1 var){ | ||
| + | return new Test2(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | public run() { | ||
| + | Test1 t1 = new Test1(); | ||
| + | Test2 t2 = t1; // in java this would result in an error. t1 cannot be automatically casted to Test2. | ||
| + | } | ||
| + | </ | ||
| + | |||
