Discuss Scratch
- Discussion Forums
- » Suggestions
- » Function that can return a value
- sebitommy123
-
13 posts
Function that can return a value
This would be extreamly usefull, especially for people who don't wan't to exit the Scratch Project making UI.
An example:
First, declare the funccion:
Then calling it:
An example:
First, declare the funccion:
Then calling it:
Last edited by sebitommy123 (July 1, 2016 21:23:12)
- __init__
-
1000+ posts
Function that can return a value
This already exists:
that can return a valueFunction
- alexphan
-
1000+ posts
Function that can return a value
In that case…duplicate.This already exists:that can return a valueFunction
Last edited by alexphan (July 1, 2016 21:01:04)
- sebitommy123
-
13 posts
Function that can return a value
No, what I refer to is first defining a funccion like so:
and then calling it like so:
and then calling it like so:
Last edited by sebitommy123 (July 1, 2016 21:21:22)
- sebitommy123
-
13 posts
Function that can return a value
This would be extreamly usefull, especially for people who don't wan't to exit the Scratch Project making UI.
An example:
First, declare the funccion:
Then calling it:
There are work arounds, but they are messy.
One is to create a variable, set it is the funccion and read it from the out side:
I think that this would remove all that mess of creating variables for returning.
An example:
First, declare the funccion:
Then calling it:
There are work arounds, but they are messy.
One is to create a variable, set it is the funccion and read it from the out side:
You do this and then call the funccion from the code.
I think that this would remove all that mess of creating variables for returning.
Last edited by sebitommy123 (July 1, 2016 21:32:31)
- helloandgoodbye9
-
1000+ posts
Function that can return a value
Yes, it is a duplicate of #1. No, what I refer to is first defining a funccion like so:
and then calling it like so:
Also, there is a chance of it being in scratch 3.
- elian_night
-
1 post
Function that can return a value
A solution that comes to my mind would be the following:
We create a special variable named RETURN (for example) and then in every function we want to return a value we instead save that value into that variable
And when we call the function to use the return value we make use of the RETURN variable.
I haven't explore this solution a lot so I don't know if it is prone to error, but even though I wanted to share it and I hope it is useful for someone.
We create a special variable named RETURN (for example) and then in every function we want to return a value we instead save that value into that variable
And when we call the function to use the return value we make use of the RETURN variable.
I haven't explore this solution a lot so I don't know if it is prone to error, but even though I wanted to share it and I hope it is useful for someone.
- Discussion Forums
- » Suggestions
-
» Function that can return a value