Static Methods & Return Blocks

A feature I’d like to see in Hopscotch is: Static Methods - Using methods (custom actions) as a variable

I’d use it for this type of project: Literally Everything

Here are some examples of Hopscotch code that could be improved if we had this: No need to run a custom action, send the result into a variable, get the variable, then use the variable, and finally empty the variable for next use.

Here is an example design I’ve made:


I def stuffed up the rainbow block colours lol

I’ve seen something similar in another programming languages, it looks like this: c# and i think in java

  • YES
  • Meh
  • No

0 voters

@IcingPuppies

10 Likes

first post

also nice idea

3 Likes

Note: this would also need a return block

Also, lol

4 Likes

Can you explain what it does. I have no idea :man_shrugging:

3 Likes

I’ve programmed in C#, so I understand what you mean by static methods. If I understand it right, you want to be able to have rainbow blocks return a variable so you can use the rainbow block directly as a variable.

So, you could do like:

[define rainbow block]
<rainbow block code here>
return (Some calculation, variable, etc)
[end of rainbow block]

Set text to (<You can then put the rainbow block directly here>)

I hope I understood it right. This would be really good to have! It would make rainbow blocks more similar to most text-based programming languages. On the other hand, it is possible to do this today by simply putting the “Set text”-block in the rainbow block, but as I said, it would make the rainbow blocks more like functions in text-based programming languages.

7 Likes

YES WE ABSOLUTELY NEED THIS

here’s a concept:

10 Likes

honestly would be super doable with parameters too – i’d love love love to see this implemented

9 Likes

Yep exactly!
@RoadOcean ^^

4 Likes

So I understood it right, cool:)) This would truly be amazing to have then!

2 Likes

hey, i just saw this ^^^ topic and i believe we can merge if necessary

2 Likes

Possibly

1 Like

I love love love this idea!

I can imagine using this to return music note lengths (quarter note, half note, etc.), it would make coding music much faster, I think.

4 Likes

Exactly!

2 Likes