How do to print two zero's 00 as an integer?

前端 未结 4 1414
萌比男神i
萌比男神i 2021-01-14 01:49

I\'m working on some app academy practice questions and I can\'t seem to print two 00\'s for my time conversion. Here\'s what I have so far:

def time_convers         


        
4条回答
  •  遥遥无期
    2021-01-14 02:11

    The method Fixnum#divmod is useful here:

    def time_conversion(minutes)
      "%d hours: %02d minutes" % minutes.divmod(60)
    end      
    
    time_conversion(360)
      #=> "6 hours: 00 minutes"
    

提交回复
热议问题