leafo/moonscript

"Adding a new method to a class after declaration" example typo

w7rus opened this issue · 0 comments

w7rus commented

I've tried to compile this example taken from here

class Player
  new: (@name) =>

  for dir in *{"north", "west", "east", "south"}
    @__base["go_#{dir}"]: =>
      print "#{@name} is going #{dir}"

Player("Lee")\go_east! --> Lee is going east

but, it fails with the following output:

.\script.moon   Failed to parse:
 [73] >>    @__base["go_#{dir}"]: =>

So instead of @__base["go_#{dir}"]: => it should be @__base["go_#{dir}"] = =>