Skip to content

Instantly share code, notes, and snippets.

@brntbeer
Created July 18, 2012 22:35
Show Gist options
  • Save brntbeer/3139422 to your computer and use it in GitHub Desktop.
Save brntbeer/3139422 to your computer and use it in GitHub Desktop.
Lua operators
foo =
bar and baz and bar[baz]
or
var and var.this and var.this.that
or
nil
@ajacksified
Copy link

foo = if bar and baz and bar[baz] then
  bar and baz and bar[baz]
else if var and var.this and var.this.that 
  var and var.this and var.this.that 
else
  nil

@DorianGray
Copy link

if(bar and baz) then
  foo = bar[baz]
else if (var and var.this) then
  foo = var.this.that()
else
  foo = nil

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