The conditional_to_if option converts ternary operators into if/else if they are over the margin:
julia> ft("a ? b : c", conditional_to_if = true)
"a ? b : c"
julia> ft("a ? b : c", conditional_to_if = true; margin=4)
"if a\n b\nelse\n c\nend"
BlueStyle goes one step further than that and converts chained ternaries into if/elseif/else, even if they aren't over the margin:
julia> ft("a ? b : c", BlueStyle())
"a ? b : c"
julia> ft("a ? b : c ? d : e", BlueStyle())
"if a\n b\nelseif c\n d\nelse\n e\nend"
However, it's inconsistent in the way it does this, and only checks for one particular way of chaining it. For example, this doesn't get converted:
julia> ft("a ? b ? c : d : e", BlueStyle())
"a ? b ? c : d : e"
The
conditional_to_ifoption converts ternary operators into if/else if they are over the margin:BlueStyle goes one step further than that and converts chained ternaries into if/elseif/else, even if they aren't over the margin:
However, it's inconsistent in the way it does this, and only checks for one particular way of chaining it. For example, this doesn't get converted: