diff options
author | 2021-11-08 18:23:27 -0500 | |
---|---|---|
committer | 2021-11-08 18:23:27 -0500 | |
commit | 1d0bd87e56a51b5c8c5a96c54c0da97470712ca7 (patch) | |
tree | c8be96cc38db2b4fe6c5692273d8430729c0dad3 | |
parent | Only re-run filters in `on_message_update` if contents/attachments changed (#... (diff) |
Make type-hint tag
-rw-r--r-- | bot/resources/tags/type-hint.md | 16 |
1 files changed, 16 insertions, 0 deletions
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. |