You are viewing a single comment's thread. Return to all comments →
def convert_temp(temp, input_scale="celsius", output_scale="celsius"): scales = { "celsius": (1, 0), "kelvin": (1, 273.15), "fahrenheit": (1.8, 32) } factor_in, offset_in = scales.get(input_scale, (1, 0)) factor_out, offset_out = scales.get(output_scale, (1, 0)) temp_celsius = (temp - offset_in) / factor_in result = (temp_celsius * factor_out) + offset_out return result end
Seems like cookies are disabled on this browser, please enable them to open this website
Ruby - Methods - Keyword Arguments
You are viewing a single comment's thread. Return to all comments →