Bradley Schaefer on Nostr: What's your preferred implementation pattern? 1) [a, b, "unknown"].compact.first 2) ...
What's your preferred implementation pattern?
1) [a, b, "unknown"].compact.first
2) [a, b, "unknown"].detect(&:itself)
3) [-> { a }, -> { b }, -> { "unknown" }].lazy.map(&:call).detect(&:itself)
4) a || b || "unknown"
And don't say "it depends" - the stakes are nothing.
#ruby
1) [a, b, "unknown"].compact.first
2) [a, b, "unknown"].detect(&:itself)
3) [-> { a }, -> { b }, -> { "unknown" }].lazy.map(&:call).detect(&:itself)
4) a || b || "unknown"
And don't say "it depends" - the stakes are nothing.
#ruby