IssueRaiser

Requst: Optional parentheses for one argument arrow function

Arrow functions, or lambdas as some languages call it, are frequently used in dart, even more so in the Flutter framework. Most of these arrow functions only contain one argument. At the language's current standing, if I were to write a `forEach` loop on a List, I would have to do something like this: ```dart void main(List<String> args) { List list = [1,2,3,4]; list.forEach((item) => /* Do something item */); } ``` `forEach` is just one of the many places that an arrow function is frequently used. As you can see, the parentheses around the `item` make the whole arrow function a little awkward to write and also read. I propose the following change: make the parenthensis around one argument arrow functions optional, permitting writing code as such: ```dart void main(List<String> args) { List list = [1,2,3,4]; list.forEach(item => /* Do something item */); } ``` This makes the code much cleaner to read and to write.

Posted by architkithania on Apr 18, 2019, 3:28 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Other)

Requst: Optional parentheses for one argument arrow function

architkithaniaApr 18, 2019, 3:28 PM

Arrow functions, or lambdas as some languages call it, are frequently used in dart, even more so in the Flutter framework. Most of these arrow functions only contain one argument. At the language's current standing, if I were to write a `forEach` loop on a List, I would have to do something like this: ```dart void main(List<String> args) { List list = [1,2,3,4]; list.forEach((item) => /* Do something item */); } ``` `forEach` is just one of the many places that an arrow function is frequently used. As you can see, the parentheses around the `item` make the whole arrow function a little awkward to write and also read. I propose the following change: make the parenthensis around one argument arrow functions optional, permitting writing code as such: ```dart void main(List<String> args) { List list = [1,2,3,4]; list.forEach(item => /* Do something item */); } ``` This makes the code much cleaner to read and to write.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue