Reputation: 4761
Given:
C = case A of
undefined ->
"";
Value ->
Value
end
How would I express this as a single line?
Upvotes: 1
Views: 281
Reputation: 90980
Besides the obvious (putting all of that code on one line), you could make a helper function like this:
with_default(undefined, D) -> D;
with_default(X, _) -> X.
with_default(X) -> with_default(X, "").
Upvotes: 3