Skip to content

Commit

Permalink
Update type-system.md (#5549)
Browse files Browse the repository at this point in the history
As mentioned by @eernstg in this
[comment](#5523 (comment)),
I've updated the code which corrects the confusion caused here. In the
doc, static type of animals is List<Animal>, but the run-time type of
animals is a type that implements List<Dog>.

Fixes [Link to
page](https://dart.dev/language/type-system#runtime-checks)

---

- [ ] I’ve reviewed the contributor guide and applied the relevant
portions to this PR.
- [ ] This PR doesn't contain automatically generated corrections or
text (Grammarly, LLMs, and similar).
- [ ] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn't use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [ ] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.
  • Loading branch information
afradahsan authored Feb 15, 2024
1 parent 59b4d26 commit 14aa9ef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/content/language/type-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ because it's an error to cast a list of dogs to a list of cats:
<?code-excerpt "test/strong_test.dart (runtime-checks)" replace="/animals as[^;]*/[!$&!]/g"?>
```dart tag=runtime-fail
void main() {
List<Animal> animals = [Dog()];
List<Animal> animals = <Dog>[Dog()];
List<Cat> cats = [!animals as List<Cat>!];
}
```
Expand Down

0 comments on commit 14aa9ef

Please sign in to comment.