Using case when in assignment
fruit = "orange" color = case fruit # ww w. j a v a 2s . c om when "orange" "orange" when "apple" "green" when "banana" "yellow" else "unknown" end
Here, we use a case block, but you assign the result of whichever inner block is executed directly to color.