Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

well, I hate to beat a dead horse, but here's a one-liner (ruby):

  (map1.keys | map2.keys).map(&:to_s).sort.join(", ").instance_eval { empty? ? "<none>" : self }


My one-liner:

a = {"fred": 4, "wilma": 8} b = {"t-shirt": 6, "fred": 0}

print ", ".join(sorted(set(a).union(b))) or "<none>"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: