#Why is it recommended to not use selection operator in code? it seems convenient
30 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @opal fern! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Well it's not "not-recommended." It's just a matter of fact of whether you're using it appropriately. Switch statements are a lot faster than if/else statements, but it is often used for conditions where it's not appropriate; hence it's not suggested to beginners.
If you understand what you're doing and can use them appropriately, go for it. (An example of proper switch use is a boolean or switching states of something). If you do decide to use selection statements, be sure to avoid using it on objects. Cheers!
They are convenient, and easy to read. If you want to learn more about the benefits/disadvantages: https://stackoverflow.com/questions/4417070/switch-statements-are-bad
it's not suggested to beginners
yeah, to add onto that i really didn't start using switch statements effectively until i was about a year into programming
if/else provides more clarity, and is introduced way earlier than switch no matter what OOP language you use. I wouldn't say switch statements are complex, but they're definitely more confusing to use "properly," when you first work with them. It still will work, just might cause a memory leak here or there since Java has terrible memory management 🤷 This isn't Rust lol
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
alright thanks! and why not use it on objects
coincidentally i'm also learning rust
(im struggling hard asf)
It may not be reached by garbage collection and can cause a memory leak
Rust is a mix of C++ and Haskell. You should learn those both prior to Rust
You can close the ticket here and thank me if this has been helpful :)
ehhhh
i think i’ll be okay
im mostly struggling with like setting it up and compiling it on my computer
i alr installed rustup im just having some trouble understanding packages and how to use them
its not like compiling java at all java is ez
Well ofc it's hard if you don't have any prior knowledge of C++ or Haskell?
not the syntax or concepts
.
just compiling
like the main new thing is memory management
and i understand that fine
ok
just make sure to close this ticket as an answer has been provided
You are very cool for using Rust. Just want to assure you, you are dope :)
ty
Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click I'm done here. Close this post!.