I need to produce a string surrounded by parenthesis but only if its value is not empty. Currently I'm using something similar to:
[5] pry(main)> a = nil
=> nil
[6] pry(main)> a.nil? ? '' : "(#{a})"
=> ""
[7] pry(main)> a = "world"
=> "world"
[8] pry(main)> a.nil? ? '' : "(#{a})"
=> "(world)"
But I consider it to be repetitive. Is there a simpler way?