Skip to content

Instantly share code, notes, and snippets.

@germandiagogomez
Last active May 25, 2021 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save germandiagogomez/04097ed03ecd64581fed78e421802527 to your computer and use it in GitHub Desktop.
Save germandiagogomez/04097ed03ecd64581fed78e421802527 to your computer and use it in GitHub Desktop.
Classes in Wren
class Counter {
construct new(withValue) {
_currentValue = withValue
}
increment() {
_currentValue = _currentValue + 1
}
value { _currentValue }
}
var c = Counter.new(0)
for (v in in 1...10.where{|e| e % 2 == 0) {
System.print("%(v)")
c.increment()
System.print("%(c.value)")
}
for (e in ["hello", "world"]) {
System.print("%(e)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment