Skip to content

Instantly share code, notes, and snippets.

@faloi
Last active July 20, 2020 20:22
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 faloi/521dfc644e07f68f8618ba2810760132 to your computer and use it in GitHub Desktop.
Save faloi/521dfc644e07f68f8618ba2810760132 to your computer and use it in GitHub Desktop.
Wollok JavaScript
====== ==========
// Booleanos
and &&
or ||
not !
// Listas (no hay conjuntos en JS de forma nativa)
add(algo) push(algo)
size() length
forEach { x => } forEach(x => )
filter { x => } filter(x => )
map { x => } map(x => )
all { x => } every(x => )
any { x => } some(x => )
// Clases
class GolondrinaWollok {
var energia = 0
method volar(kms) {
energia -= kms * 2
}
method energia() {
return energia
}
}
class GolondrinaJS {
constructor() {
this._energia = 0
}
volar(kms) {
this._energia -= kms * 2
}
energia() {
return this._energia
}
}
@PalumboN
Copy link

PalumboN commented Jul 2, 2019

Se podría agregar:

// Objetos

object manzanaWollok {                           
  method energia() {
    return 20
  }

  method esFruta() {
    return true
  }
}

var manzanaJS = {
  energia() {
    return 20
  }, //<-- En los objetos va ',' para separar los métodos!

  esFruta() {
    return true
  }
}

@faloi
Copy link
Author

faloi commented Jul 3, 2019

¿Y con el this qué hacemos? ¿Y los atributos? Me parece que no hay una buena equivalencia entre objetos Wollok y objetos JS.

@PalumboN
Copy link

¿Y con el this qué hacemos? ¿Y los atributos? Me parece que no hay una buena equivalencia entre objetos Wollok y objetos JS.

Eso ya no funciona bien en JS? :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment