Skip to content

Instantly share code, notes, and snippets.

@HenriqueSilverio
Created May 4, 2025 23:29
Show Gist options
  • Save HenriqueSilverio/0966280631a3fc0bfea3d37ddaecbf33 to your computer and use it in GitHub Desktop.
Save HenriqueSilverio/0966280631a3fc0bfea3d37ddaecbf33 to your computer and use it in GitHub Desktop.
class False {
not() {
return new True()
}
or(aBoolean) {
return aBoolean
}
toString() {
return 'false'
}
}
class True {
not() {
return new False()
}
or(aBoolean) {
return this
}
toString() {
return 'true'
}
}
const falsy = new False()
const truthy = new True()
console.log(`falsy.not(): ${falsy.not()}`)
console.log(`falsy.or(truthy): ${falsy.or(truthy)}`)
console.log(`falsy.or(falsy): ${falsy.or(falsy)}`)
console.log(`truthy.not(): ${truthy.not()}`)
console.log(`truthy.or(falsy): ${truthy.or(falsy)}`)
console.log(`truthy.or(truthy): ${truthy.or(truthy)}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment