exercism / dart

Exercism exercises in Dart.
https://exercism.org/tracks/dart
MIT License
57 stars 94 forks source link

Syntax question -- lists, and types and lists of lists #438

Closed kytrinyx closed 1 year ago

kytrinyx commented 1 year ago

Sometimes lists have a type specifier, and sometimes they don't:

https://github.com/exercism/dart/blob/3fa379a4c23838386eca656d71e6aebfabf572c8/exercises/practice/pascals-triangle/test/pascals_triangle_test.dart#L91

https://github.com/exercism/dart/blob/3fa379a4c23838386eca656d71e6aebfabf572c8/exercises/practice/forth/test/forth_test.dart#L292

How do you decide when to add the type specification or not?

Would you prefer to always have it, or only have it if the list is empty and you can't infer the type?

Stargator commented 1 year ago

It depends. I do think all of our lists are of the same type and not mixed types

So if that's true, then I'm fine with the latter and inferring types.

I think some of this is leftover from previous versions of Dart where the inference wasn't as accurate.

As long as dart analyze is happy.

kytrinyx commented 1 year ago

As long as `dart analyze is happy.

Ok, thank you. That's a useful rule of thumb!