Ruby - Methods - Keyword Arguments

  • + 1 comment

    I'm with a problem with my code, because it works when I run it on VScode, but when I try on HackerRank, it don't works

    def convert_temp(temperature,input_scale:,output_scale:'celsius') if input_scale=='celsius' if output_scale=='kelvin'

      temperature+=273.15
    
    elsif output_scale=='fahrenheit'
    
      temperature=((temperature*9/5)+32).to_f
    
    end
    

    elsif input_scale=='kelvin'

    if output_scale=='celsius'
    
      temperature-=273.15
    
    elsif output_scale=='fahrenheit'
    
      temperature=(((temperature-273.15)*9/5)+32).to_f
    
    end
    

    elsif input_scale=='fahrenheit'

    if output_scale=='celsius'
    
      temperature = ((temperature-32)*5/9).to_f
    
    elsif output_scale=='kelvin'
    
      temperature =(((temperature-32)*5/9)+273.15).to_f
    end
    

    end end

    puts convert_temp(0, input_scale: 'celsius', output_scale: 'kelvin')