Discuss Scratch
- Discussion Forums
- » Suggestions
- » ?-Operator [inline if-then-else]
- mybearworld
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Reported it to be mergedmerge plsDuplicate. This link was mentioned before in this topic.
- PTheGreat42
-
Scratcher
100+ posts
?-Operator [inline if-then-else]
This can be workarounded easily.Workarounds for a suggested block don`t mean that block shouldn`t be added.if <key [space v] pressed?> thenNo support
say [Key space is pressed] for (2) secs
else
say [Key space is not pressed] for (2) secs
end
- Scratchperson1000000
-
Scratcher
500+ posts
?-Operator [inline if-then-else]
We need this block:(removed - no message)(if<>then[]else[]::operators)Like they have in some Scratch mods.
If the boolean in the block reports true, it reports the first value. Otherwise, if false, it reports the else value.
For an example:when gf clicked
ask[Are you cool?]and wait
say(if<(answer)=[yes]>then[Good!]else[What!?]::operators)for(2)secs
EDIT: AND CLOSE YOUR TAGS
Last edited by Scratchperson1000000 (Feb. 24, 2021 18:57:21)
- historical_supa
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Support, the workaround is kinda time-consuming.
- IdkbutprobablyAmogus
-
Scratcher
100+ posts
?-Operator [inline if-then-else]
So wait, what's the problem withwhen green flag clickedYou didn't say anything about how the boolean could be useful, you just said how it works and what it does. Unless there are some pros or cons listed, I think I'll stick to -1
ask [Are you cool?] and wait
if <> then
say [Good!] for (2) secs
else
say [What!?] for (2) secs
end
when green flag clicked::operators
move (10) steps::operators
- Quantum-Cat
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
My opinion is on between in this. On one hand, this is efficient and really useful, decreasing the need for variables and if-else stacks every time you want to do something similar, and can be seen in other programming languages (e.g. the ternary ?: operator). But does everything in other languages that can simplify code be implemented? In that case, there are a lot of things that can be put, but would clutter the area. Scratch, being a drag-and-drop language, aims to offers what is needed for most users to do what they want, with a limited capacity for blocks.
- windows-11-pro
-
Scratcher
100+ posts
?-Operator [inline if-then-else]
(#2)this is better (in one line)
Basically, an in-line if-then-else construct. Handy, certainly, but nothing that can't be done fairly well with other blocks. For instance, on your last example, you could do the same thing with this:if <(pick random (1) to (2)) = [1]> then
set [value v] to [1]
else
set [value v] to [-1]
end
Perhaps even more easily understood than the in-line version.
set [value v] to ((-1) + (<(pick random (1) to (2)) = [1]> * (2)
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Judging by how it looks, I think from Snap!
how did you get the block?
- medians
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
No, that's Scratch 2.0, 2.0 blocks look different from Snap and 1.x.Judging by how it looks, I think from Snap!
how did you get the block?
Last edited by medians (July 8, 2024 20:31:05)
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Oh wait, Snap! doesn't have a light mode (just like Scratch 3 doesn't have an official dark mode.)No, that's Scratch 2.0.Judging by how it looks, I think from Snap!
how did you get the block?
Alright then, how DID you get that block?
- medians
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
I mean, there's kind of a light mode if you turn on flat design (I do not like how that looks though), so:Oh wait, Snap! doesn't have a light mode (just like Scratch 3 doesn't have an official dark mode.)No, that's Scratch 2.0.Judging by how it looks, I think from Snap!
how did you get the block?
Alright then, how DID you get that block?
I used Edit Block Colors and used an old version of 2.0, and then created a list like that using a bug that appeared in earlier versions of 2.0, where block specs would show up if you put them in list names, custom block names, and variable names:
https://en.scratch-wiki.info/wiki/Argument#Use_in_block_specs_(Scratch_2.0)
Last edited by medians (July 8, 2024 20:36:06)
- starlightsparker
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Isn’t that just
if <> then
else
end
- medians
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Isn’t that justIt is basically this, but this is easier since you do not have to create a result variable or anything, and can fit in reporter inputs (also, this has been used in other places too):if <> then
else
end
if <bool::grey> then
set [result v] to (first result::grey)
else
set [result v] to (second result::grey)
end
- starlightsparker
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Is there a clear benefit to fitting in Boolean inputs? In what situation would it be needed? /genIsn’t that justIt is basically this, but this is easier since you do not have to create a result variable or anything, and can fit in reporter inputs (also, this has been used in other places too):if <> then
else
endif <bool::grey> then
set [result v] to (first result::grey)
else
set [result v] to (second result::grey)
end
- medians
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Is there a clear benefit to fitting in Boolean inputs? In what situation would it be needed? /genTo prevent multiple if statements, and if there are block inputs in the future, it could be used for that too.
Also, what do you mean by boolean?? You mean reporter??
Last edited by medians (July 8, 2024 21:18:41)
- ajskateboarder
-
Scratcher
1000+ posts
?-Operator [inline if-then-else]
Yes because code can be made more concise (usually) while still being readable (in a lot of cases)Is there a clear benefit to fitting in Boolean inputs? In what situation would it be needed? /genIsn’t that justIt is basically this, but this is easier since you do not have to create a result variable or anything, and can fit in reporter inputs (also, this has been used in other places too):if <> then
else
endif <bool::grey> then
set [result v] to (first result::grey)
else
set [result v] to (second result::grey)
end
- Discussion Forums
- » Suggestions
-
» ?-Operator [inline if-then-else]















