module Opal::Nodes::Helpers

def conditional_send(recvr)

Parameters:
  • recvr (sexp_pushable) -- The receiver of the call that will be
def conditional_send(recvr)
  # temporary variable that stores method receiver
  receiver_temp = scope.new_temp
  push "#{receiver_temp} = ", recvr
  # execute the sexp only if the receiver isn't nil
  push ", (#{receiver_temp} === nil || #{receiver_temp} == null) ? nil : "
  yield receiver_temp
  wrap '(', ')'
end