Share the Fruit of the Spirit: Love, Joy, Peace, Patience, Kindness, Goodness, Faithfulness, Gentleness, Self-control
"If you lie to the computer, it will get you."
Favorite Granny's Wisdom Pearl
D.J. Quavern wrote:... I attached a screenshot to show what I mean
...
Share the Fruit of the Spirit: Love, Joy, Peace, Patience, Kindness, Goodness, Faithfulness, Gentleness, Self-control
"If you lie to the computer, it will get you."
Favorite Granny's Wisdom Pearl
D.J. Quavern wrote:Took the liberty to share another screenshot where type annotation is extremely useful, if it is ok
...
Share the Fruit of the Spirit: Love, Joy, Peace, Patience, Kindness, Goodness, Faithfulness, Gentleness, Self-control
Geoff McKay wrote:Congrats Ken Youens-Clark on your new book Command-Line Rust: A Project-Based Primer for Writing Rust CLIs.
With some languages it's necessary (or best practice) to define a variable's Type. (e.g. String, Numeric, Integer, etc.)
With Rust CLIs, is it best practice (or required) to specifically define a variable's Type?
Sometimes it's easier to read code if a variable Type is specifically defined initially, and this can help prevent potential confusion or debugging issues.
Using PHP as an example, you can specify a Type of Variable instead of allowing PHP to set this automatically based on how the variable is used. (I have heard people say PHP is a weak typed language, because you are not required to declare variable type)
What are best practices regarding Variable Type Declaration in Rust CLIs?
Ken Youens-Clark wrote:... I would say it's best practice to use type annotations as much as possible... Some people find it abominable to declare types in Python, but I find it far easier to read and use tools like pylint/flake8/mypy to check my code....
Share the Fruit of the Spirit: Love, Joy, Peace, Patience, Kindness, Goodness, Faithfulness, Gentleness, Self-control