Discuss Scratch

GarryHatesScratch
Scratcher
1 post

Switch-block

Something like this would be cool:
switch (letter) {
case [a] {
} :: control
case [b] {
} :: control
case [c] {
}:: control
} :: control
banana439monkey
Scratcher
1000+ posts

Switch-block

see i would see this:

switch (item) :: control // this and the case block would be fused together, other case blocks would not be fused together but can only be used in this context
case [...] {
...
} case [...] {
...
} :: control // this case block and beyond would not be fused to switch. the reason the first case was fused was so that no other blocks can be used underneath switch
case [...] {
...
} :: control
default {
...
} :: control // If none of the cases are met, then do this

i was thinking of a
break :: control
block but i feel that if a case is met it should break the switch/case statement anyway (else we risk seriously confusing users if multiple cases listed is the case and by default we run through all of the cases that are true)
i would love to see it but could probably bring up some form of errors?

Banana

Last edited by banana439monkey (May 4, 2023 13:41:35)



Banana
——————————————————————————–

Very inactive user who has now become a maker.
If you reply to this post it would be greatly appreciated if you could comment the link to your post on my profile!!!

-SkysBane-
Scratcher
48 posts

Switch-block

A-no-meep wrote:

davidkt wrote:

Firedrake969 wrote:

davidkt wrote:

Mockup:
switch (variable) ::control // pretend it's joined with the block below
case (1)::cstart control
...
case (2)::celse
...
case (3) + - ::celse
...
default ::celse
...
end
Anyway, support.
Would we want optional breaks or not?
Not. It would be too confusing, and there aren't going to be many circumstances where you'll need to not have the break.
Agreed. Most instances of deliberately not having break can be solved with duplicate.


I think you should have a “break” block because it could be used for other things as well, like breaking out of while loops, forever loops, and the switch statement

stop [break v]

The default fallthrough of the switch statement can actually be useful, and I think it would allow for some more efficient and interesting programs. It might be hard for people to learn, but that's what tutorials are for. I think it would be useful for a lot of reasons. The broadcast version of a switch statement is nice, but you can't do fallthrough and it doesn't happen in the same tick.




-SkysBane-

Click here for latest game: Men In Pen || 100% Pen

:0
gdfsgdfsgdfg
Scratcher
1000+ posts

Switch-block

Why are my posts dustbinned?


1000th post also use -forbidden- or highlight and ctrl (optional on some browsers) + shift + down arrow for more of my siggy


We have the craps ®

I gotta go touch sum grass

If it causes issues make it optional - gdfsgdfsgdfg

Do some research before replying to my posts - gdfsgdfsgdfg

curse you 60 sec rule

glory to Gdfsg Land

gdfsgdfsgdfg returns

Ocular(don’t look at my old posts plz)
PostPercent

kumquats? nah
my siggy is built with titani- *gets eaten*

Gdfsg Radio Station:
https://scratch.mit.edu/projects/1000736602

Are you sleeping you tall cat (project):
https://scratch.mit.edu/projects/1002042247/

The only suggestions I fully support are:
https://scratch.mit.edu/projects/924995948/

Don’t force me to get proof
get it yourself

my favorite topic is this (due to comedic purposes):
https://scratch.mit.edu/discuss/topic/709979/

my favorite post is this (it’s deleted but I got it from ocular):
https://ocular.jeffalo.net/post/7517300

Grand borrowing cars IV intro and loading (template):
https://scratch.mit.edu/projects/972295666/

Guess the game by its mission name:
https://scratch.mit.edu/discuss/topic/750145/

GBC (GTA) topic:
https://scratch.mit.edu/discuss/topic/751981/

BF (Battlefield) topic:
https://scratch.mit.edu/discuss/topic/753243/

still don’t have the popularity lol (atleast I reached 100 followers)

Skill issue

reject
Embrace :)
ophizma
Scratcher
1 post

Switch-block


set (letter) to (switch)
broadcast (letter)

Last edited by ophizma (Aug. 7, 2023 20:13:24)

mumu245
Scratcher
1000+ posts

Switch-block

Mockup:
// if a case is true, runs the code and exits the switch
switch () {
case () {
. . .
} ::control
case () {
. . .
} ::control
else {
. . .
} ::control cap
} ::control

select this text then press Ctrl+Shift+Down to read more

Powered by DjangoBB