evanw / skew

A web-first, cross-platform programming language with an optimizing compiler
https://evanw.github.io/skew-lang.org/
MIT License
413 stars 16 forks source link

List methods usage #18

Open mationai opened 8 years ago

mationai commented 8 years ago

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 commented 8 years ago

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

jlfwong commented 7 years ago

@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)