algorithmic modeling for Rhino
"Not all code paths return a value" means that under certain conditions your function does not return a value at all. Basically, when inp <= 0.5 then your function does not return a value, you need to fix this by adding another return statement.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi Andrea,
in C# you must make sure that all function code paths return a value, and you need to do this in an explicit way. In the case above,
return 1.2; is only executed if inp is larger than 0.5.
You need to work out what happens in all other case, for example if inp is strictly less than 0.5, and also what is returned if it is exactly 0.5. In particular, C# checks for example that there is always a return value by seeing if there is an else with return, or there is a final return at the end of the method.
For example, something like this will work:
public double re(double inp)
{
if (inp > 0.5) { return 1.2; }
else if (inp < 0.5) { return 2.0; }
else { return 0.0; }
}
You can also skip the { } after if() and else, if you only have one statement.
I'd suggest to read a book about C# if you have a little time. Everything will become a lot clearer.
For example, there is the Programmers' Heaven C# book you can read for free.
I hope it helps,
- Giulio
______________
giulio@mcneel.com
This is the file.
thank you,Giulio,i am reading the book you have recommended,Grazie!
I did read a book by Jesse Liberty on C# and that was useful for me back then.
- Giulio
______________
giulio@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by