dart-lang / dart-lang/language
Add * operator to elements in a list
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
For string, we have the `*` operator, which as we know turns a single item into multiple.
This would be handy in `Lists` for example, instead of writing
```dart
[MyObject(), MyObject() ,MyObject()]
```
It would be easier to write, [...MyObject() * 3]
I do, however, see a huge issue with this if the object has a `*` operator defined, then how would you know the difference...
> operator * method
> String operator * (
> int times
> )
> Creates a new string by concatenating this string with itself a number of times.
>
> The result of str * n is equivalent to str + str + ...(n times)... + str.
>
> Returns an empty string if times is zero or negative.
>
> Implementation
> String operator *(int times);
Contributor guide
Assessment
This issue has not been assessed yet.