Suggestion: Check if else blocks in parameters

A feature I’d like to see in Hopscotch is:

Check if else blocks in parameters
Basically it gives a certain output depending on the condition.
Set text to ((if (1 = 1) then (yes) else (no));
The above block will output yes if 1 = 1 or no if 1 ≠ 1.

I’d use it for this type of project:

Everything

Here are some examples of Hopscotch code that could be improved if we had this:

Places where there’s a condition for the input, like ‘must be a number’

Here is an example design I’ve made:


Uh (budget block tiiime!)

(If (((self) clone index) = (0)) then (original object) else (clone))

I’ve seen something similar in another programming languages, it looks like this:

I’ve seen this in kotlin
Smth like:

Val  x :int = if (7 = 3) {
"What"
} else if (7 == 7) {
"Yes"
}
13 Likes

this is 100% epic and will save a lot of time

7 Likes

epic idea man!

7 Likes

community-abed

6 Likes

Wow, I’ve never thought of this before. Great idea! This would definitely save time.

2 Likes

Awesome ideas!!

1 Like

:+1::+1::+1::+1: yes this is great

1 Like

I’ve used this a lot in Python and it would be awesome to have in Hopscotch! Great suggestion.

2 Likes

Maybe when is between also

1 Like

It would be soooooo useful!

:+1: Outstanding Suggestion!

1 Like

To be honest, I’m not so keen on this idea, doing this (at least in C, Java, and python. I’m pretty sure it’s not recommended in other languages, too). It’s a lot more clear when you have

if(condition){
    var = something;
}
else{
    var = something_else;
}

As opposed to:

var = (condition) ? something : something_else;

Especially when mixed together with other code.

This is just my (and others’) opinions, and of course you don’t have to share them.

6 Likes

I need this

2 Likes

Really useful @The_Electogenius.

1 Like

Yes, it can look confusing but it is very efficient, maybe make it a bright blue so it can be recognized easily?

2 Likes

yeah i agree

1 Like

I still really don’t see a point to this. An if/else statement is a lot more clear, and adding a one line if/else statement will just hurt the readability of a project.
Programming is all about readability, so other people can easily read and understand what you wrote, so they can help you. Adding this, in my mind, will cause more harm than good for projects. But then again, it’s not up to me. Still a nice idea though.

2 Likes

Yeah you can use check if else and just copy paste the block, basically this “saves time” saves like 3 seconds

2 Likes

That’s a lot actually
I can eat 2 tons of lasagna in that time

3 Likes

Impressive i guess…

Ur stomach good lol?

2 Likes