# What does the return 0 block does

**URL:** <https://forum.makecode.com/t/what-does-the-return-0-block-does/3204>\
**Category:** Help\
**Created:** [August 23, 2020, 1:08pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204 "2020-08-23T13:08:14Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:39pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/41 "2020-08-24T20:39:38Z")

</div>

Where will it return 0 to

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:40pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/42 "2020-08-24T20:40:07Z")

</div>

is it almost like a repeat block or something

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:41pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/43 "2020-08-24T20:41:54Z")

</div>

Say we have this situation:

 ![20200824_164121](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/bc11d380f397adce9daf86c0bd2036ae499003f0.png)

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:42pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/44 "2020-08-24T20:42:44Z")

</div>

will the text be 0

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:43pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/45 "2020-08-24T20:43:05Z")

</div>

It will first call `return_zero`, which returns 0. That gets passed to `convert _ to text`, which takes that 0 into “0”. Finally It takes that “0” and passes it to show long text, which displays 0

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:43pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/46 "2020-08-24T20:43:30Z")

</div>

Yes you are correct!

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:44pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/47 "2020-08-24T20:44:28Z")

</div>

Today, I have learned what a return block does, almost

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:45pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/48 "2020-08-24T20:45:23Z")

</div>

Do you have any other cases where you don’t understand?

Or any questions?

Oh jeez, I’m starting to sound like a teacher

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:45pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/49 "2020-08-24T20:45:36Z")

</div>

I should bookmark this conversation so I can come back to it

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:46pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/50 "2020-08-24T20:46:02Z")

</div>

You feel like a teacher to me

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:46pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/51 "2020-08-24T20:46:12Z")

</div>

Those functions I showed you, they also use the return block

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:47pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/52 "2020-08-24T20:47:03Z")

</div>

I’m so sorry, I going overboard with this

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:47pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/53 "2020-08-24T20:47:23Z")

</div>

nah it was me for asking all those questions

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 24, 2020, 8:47pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/54 "2020-08-24T20:47:53Z")

</div>

I understand most of it. I think I know how to use it now

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 24, 2020, 8:50pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/55 "2020-08-24T20:50:30Z")

</div>

Nice!

The knowledge you learned today will help you write much cleaner code.

If you ever have questions, just ping me. I should respond within a day.

> The knowledge you learned today will help you write much cleaner code.

Sounds like it came directly out of the “How to speak like a teacher” guide

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [August 25, 2020, 12:25am UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/56 "2020-08-25T00:25:46Z")

</div>

Lots of great discussion in this thread! One other thing that I think is important to note is that you don’t have to just return numbers; you can return any value you have! For example, this code has a `create my enemy!` function that creates a special skeleton:

 ![arcade-screenshot](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/12b99dde3be6ccef01eabf6490665615eab1ac8c.png)

> **[Untitled](https://arcade.makecode.com/73113-27977-65290-49334)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

This is like making your own blocks that create things – exactly how you would do it if you were to make your own `projectile` block, or anything like that.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 25, 2020, 2:59am UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/57 "2020-08-25T02:59:58Z")

</div>

Oh yes, a good thing to remember. I thought you could only return numbers! (And booleans, but that’s just 0s and 1s internally)

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 25, 2020, 10:53am UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/58 "2020-08-25T10:53:20Z")

</div>

I bet you used the numbers to change the color

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 3, 2020, 3:22pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/59 "2020-10-03T15:22:49Z")

</div>

The idea of returning a value from a function is great, what @UnsignedArduino mentioned ([What does the return 0 block does](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/43)).

However in the function that returns a sprite, the sprite is still defined outside the function (as if it a global variable), and then set within the function. See the resulting script:

let my\_enemy: Sprite = null  
function create\_my\_enemy () {  
my\_enemy = sprites.create(img`removed`, SpriteKind.Player)  
my\_enemy.setPosition(randint(0, 60), randint(0, 60))  
my\_enemy.setVelocity(50, 50)  
my\_enemy.image.replace(1, randint(1, 14))  
return my\_enemy  
}

Is this a limitation of block code and/or because Sprite is complex type (class)? Does this only work for simple types (int, bool, string, etc)?

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 3, 2020, 3:39pm UTC](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204/60 "2020-10-03T15:39:17Z")

</div>

@UnsignedArduino & @jwunderl

I have defined a function that accept parameters and returns an integer. But I cannot use a return block that uses that function (see function _calculate\_distance\_4_

Just curious. 🤔

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c6c09ac0a2e7c458ee45c63c85d0ebe111a8ff6e.png)

[Previous page](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204.md?page=2)

[Next page](https://forum.makecode.com/t/what-does-the-return-0-block-does/3204.md?page=4)
