# Create function with "return"

**URL:** <https://community.thunkable.com/t/create-function-with-return/1248086>\
**Category:** Questions about Thunkable X\
**Created:** [April 27, 2021, 9:26am UTC](https://community.thunkable.com/t/create-function-with-return/1248086 "2021-04-27T09:26:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas.sjdtomypv](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andreas.sjdtomypv](https://community.thunkable.com/u/andreas.sjdtomypv)\
**Post date:** [April 27, 2021, 9:26am UTC](https://community.thunkable.com/t/create-function-with-return/1248086/1 "2021-04-27T09:26:24Z")

</div>

Hi.  
I am a bit confused and I am wondering if anyone can explain to me why this is happening:

I want to create a function with a return:  
 ![Screenshot 2021-04-27 at 11.16.29](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/9/49ba97f5fb917e1966d917a994e2b9ec929c8476.png)

But I get confused.  
When I create this function and then want to call it, it is now looking like this:

 ![Screenshot 2021-04-27 at 11.12.29 (2)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/d/fdbc1df5dbfa8ffc96b9cb05f1e255a160088058.jpeg)

See the different from the function: “do something”?

And if I want to add the piece “return”, then the output is closing, so there is no way to add any output for the return…

 ![Screenshot 2021-04-27 at 11.12.40 (2)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/4/7419d963a606cf5e425824d2604cdbfac7022b15.jpeg)

Is this normal behaviour? How can I do something like this then: (which I want to) ?

 ![Screenshot 2021-04-27 at 11.24.44](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/d/4d8e0692685f82c5a61089c725a480dfd7b8d566.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)\
**Post date:** [April 27, 2021, 10:51am UTC](https://community.thunkable.com/t/create-function-with-return/1248086/2 "2021-04-27T10:51:18Z")

</div>

Hi there,

If a function returns a given value, then that function will appear as a value block so that the value it returns can be used in other blocks, like this:

 ![Screen Shot 2021-04-27 at 11.48.29 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/3/e3e29c49261455116443c9c023055e0c4fb798ad.png)

Where are you finding this return block that does not allow you to specify the value to return?

I still see the usual return block that lets you attach a value:  
 ![Screen Shot 2021-04-27 at 11.48.12 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/a/fac277d7e0780a7b2803291114626f578305f0a8.png)

Which allows you to do something like this, or like the sample function you posted:

 ![Screen Shot 2021-04-27 at 11.48.22 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/6/964983ced3b0147ecf5aedfed75eba68bee52144.png)

---

<div class="post-metadata">

**Author:** ![andreas.sjdtomypv](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andreas.sjdtomypv](https://community.thunkable.com/u/andreas.sjdtomypv)\
**Post date:** [April 27, 2021, 11:21am UTC](https://community.thunkable.com/t/create-function-with-return/1248086/3 "2021-04-27T11:21:06Z")

</div>

Thanks for your reply.  
Well, I do see these also, but as soon as I “add” the block to the project the “output” disappears.  
Or if I have created a function with a return block from start, I won’t be able to just call it later, I need to add it as an “output”…  
See what I mean?

If I use the simple “create function-block”, without any return - I can call this to any block later.

If I create a function WITH return, I can not call that in the same way as the other function, I need to “add” it as an output/value somewhere…

If I creat a simple function without return and then ADD a return block to that function, the “output-opening” is closing, so I can’t add anything there later on…

Please see video shot here:

> **[andreas sjöstedt sent you 1 item](https://www.dropbox.com/t/dRQyr3SNCL8TNJl1)**
>
> Screen Recording 2021-04-27 at 13.08.11.mov

I am sorry for my bad “code-languish”, I am not sure how to formulate my self.

Maybe this is a completely normal behaviour, it’s just that I don’t understand it… So I need to ask.

Thanks

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 27, 2021, 6:17pm UTC](https://community.thunkable.com/t/create-function-with-return/1248086/4 "2021-04-27T18:17:49Z")

</div>

Does it help to know that you can change a variable (any variable’s) value from within a standard function?

The function with return block is really only for times when you need to have the returned value immediately available as a block. Otherwise, you can just use the standard function block.

I’ve never used the standalone “return” block in a function. I’m honestly not sure what it does.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 27, 2021, 6:22pm UTC](https://community.thunkable.com/t/create-function-with-return/1248086/5 "2021-04-27T18:22:22Z")

</div>

Can you explain what you want the function to do?

For example, I might say “I want to calculate the square root of a number the user types in” or “I want to sort a list I have stored in a variable in reverse order.”

What is it you’re actually wanting to do with functions?

---

<div class="post-metadata">

**Author:** ![andreas.sjdtomypv](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andreas.sjdtomypv](https://community.thunkable.com/u/andreas.sjdtomypv)\
**Post date:** [April 28, 2021, 7:12am UTC](https://community.thunkable.com/t/create-function-with-return/1248086/6 "2021-04-28T07:12:23Z")

</div>

Thanks!  
Yea, I want to loop/repeat my call for my data list until there is something in the list, and if there never gets anything in that list (It’s empty) I want to “break” that loop after a wile by just RETURN to my empty list…

Thanks!

---

<div class="post-metadata">

**Author:** ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)\
**Post date:** [April 28, 2021, 12:18pm UTC](https://community.thunkable.com/t/create-function-with-return/1248086/7 "2021-04-28T12:18:28Z")

</div>

Hi there,

In this video, you drag out a function that does not return a value.  
Can you drag out the second function block, that does contain a return block, and see if that works in your app? It’s called ‘do something and return’ in this video.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/create-function-with-return/1248086/8 "2024-11-08T13:22:54Z")

</div>


