you are viewing a single comment's thread
view the rest of the comments
[–] 12 points 2 years ago* (last edited 2 years ago) (5 children)

return a and a or b → return a or b

correction from @murtaza64

  • source
  • hideshow 5 child comments
  • [–] 3 points 2 years ago* (1 child)

    You don't need the and right? Can't it just be return a or b

    This doesn't work if a is falsy non-null actually

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 2 years ago

    it’s just return a and b or c is the closest Lua has to a ternary operator, but yes, for the above you could shorten it to return a or b (“or returns the first argument if true, otherwise second argument is returned”)

  • source
  • parent