Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

List methods usage #18

Open
mationai opened this issue Oct 12, 2016 · 2 comments
Open

List methods usage #18

mationai opened this issue Oct 12, 2016 · 2 comments

Comments

@mationai
Copy link

How are List methods like map and filter used? Tried the following:

  var l List<int> = [1,2]
  l.map((x int) => x + 1)

gave error:

<stdin>:5:3: error: Cannot use unparameterized type "List.map" here
  l.map((x int) => x + 1)
@mationai
Copy link
Author

Also, how to print values that doesn't have toString method like a list?

@jlfwong
Copy link

jlfwong commented Mar 9, 2017

@fuzzthink For the first thing, you need to specify the return type of the function you're passing. Like this:

  var l List<int> = [1,2]
  l.map<int>((x int) => x + 1)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants