this post was submitted on 06 Jul 2023
78 points (100.0% liked)
Programming
17668 readers
219 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I never understood this argument. If your function is supposed to take an int, then parse your string before calling it?
There are reasons you might want to, such as you are constructing something that has a few different ways to create it. Like maybe a date, can parse it from a string, pass in each bit as a separate argument, take in a Unix timestamp.
A lot of languages encourage this with constructors as you can often only have one.
IMO it is far better to just have different functions for each type you want to build something from like how it is done in rust.
But when you come from a language that encourages the opposite it can seem clunky to have to define separate functions for each. And it can take a while to accept the different way of working.