Created
November 2, 2017 23:27
-
-
Save drocco007/8ff7387b76a33d92913ec6e7472f653d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nope = false | |
yep = true | |
deep_true = | |
enabled: true | |
deep_false = | |
enabled: false | |
is_enabled = (obj) -> | |
if obj?.enabled? | |
obj.enabled | |
else if obj? | |
!!obj | |
else | |
true | |
console.log is_enabled() | |
console.log is_enabled null | |
console.log is_enabled nope | |
console.log is_enabled yep | |
console.log is_enabled {} | |
console.log is_enabled enabled: null | |
console.log is_enabled deep_false | |
console.log is_enabled deep_true | |
funtest = | |
fun: -> 42 | |
console.log funtest.fun() | |
console.log funtest.no_fun?() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment