|
Author |
Topic: function return and int()? (Read 2056 times) |
|
lunetta
|
function return and int()?
« on: May 2nd, 2004, 1:18am » |
|
hello to all processers I have a simple question on function syntax; int test() { return( int(5.5) ); } void setup() {} void draw() { println(test()); } Why this doesn't work, while int test() { int x = int(5.5); return( x ); } void setup() {} void draw() { println(test()); } this works? any particular reason? (sorry about the dumb question, I just want to understand the concept behind this...) Thanks to all!
|
|
|
|
arielm
|
Re: function return and int()?
« Reply #1 on: May 2nd, 2004, 2:43am » |
|
one syntax that always work when "type-casting" is, e.g: Code: like in Code:int test() { return (int) 5.5; } |
| concerning the "int(something)" syntax, i think it's not in the java language, but rather a helper provided by the processing preprocessor (the same way: assigning a value of 5.5 instead of 5.5f to a float will work in processing but not with a standard java compiler...)
|
Ariel Malka | www.chronotext.org
|
|
|
lunetta
|
Re: function return and int()?
« Reply #2 on: May 2nd, 2004, 3:18am » |
|
thanks Ariel! by the way, you just made me realize that if I erase the parenthesis out of the return statement, it works... I'll start to use the other syntax anyway. Real Thanks!
|
|
|
|
fry
|
Re: function return and int()?
« Reply #3 on: May 4th, 2004, 12:56am » |
|
hm, that stinks.. preprocessor bug..
|
|
|
|
|