From 1d0bd87e56a51b5c8c5a96c54c0da97470712ca7 Mon Sep 17 00:00:00 2001 From: SavagePastaMan <69145546+SavagePastaMan@users.noreply.github.com> Date: Mon, 8 Nov 2021 18:23:27 -0500 Subject: Make type-hint tag --- bot/resources/tags/type-hint.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bot/resources/tags/type-hint.md diff --git a/bot/resources/tags/type-hint.md b/bot/resources/tags/type-hint.md new file mode 100644 index 000000000..5ffbd07c3 --- /dev/null +++ b/bot/resources/tags/type-hint.md @@ -0,0 +1,16 @@ +**Type Hints** + +A typehint indicates what type something should be. For example, +```python +def add(a: int, b: int) -> int: + sum: int = a + b + return sum +``` +In this case, `a` and `b` are expected to be ints, and the function returns an int. We also declare an intermediate variable `sum`, which we indicate to be an int. + +It's important to note these are just hints and have no runtime effect. For example, +```python +#uh oh +add("hello ", "world") +``` +This code will run without error, even though it doesn't follow the function's type hints. -- cgit v1.2.3