How to return an instance of a composite type based on a given field value?

Is this what you are looking for?

julia> battle(x::warrior, y::warrior) = x.strength > y.strength ? x : y
battle (generic function with 1 method)

julia> battle(Legolas, snakeeyes)
ninja(12, "stealth")
3 Likes