So in Python sum([]) will yield 0, which is pretty important.
Whereas in ruby [].reduce(:+) will give nil, of course the ternary operator isn't a replacement, because:
(my_complicated_mapping).empty? ? 0 : (my_complicated_mapping).reduce(:+)
Will call my_complicated_mapping twice. Therefore the obvious method is:
res = my_complicated_mapping
res = (res.empty? ? 0 : res.reduce(:+))
I think there must be a neater way to do this though.
nil.to_i #=> 0, so you could tackto_iontoreduce, but I wouldn't recommend it. Just do as @mikej suggests.