The documentation of the wren scripting language http://wren.io/ explains how to define methods within a class, but I want to define a simple function and not a method. I tried this:
#! /usr/bin/env wren
square(n) {
return n * n
}
System.print(square(3))
and this (omitting the parts other than the attempted function definition:
var square= {|n|
return n * n
}
and this
var square= Fn.new {|n|
return n * n
}
but nothing worked.
Any advice how I could make it work without resorting to method definitions?