• 0 Posts
  • 72 Comments
Joined 1 year ago
cake
Cake day: July 31st, 2023

help-circle











  • paholg@lemm.eetoProgrammer Humor@programming.devExam Answer
    link
    fedilink
    English
    arrow-up
    21
    ·
    8 months ago

    Works even better in Ruby, as the code as given is valid, you just need to monkey patch length:

    #!/usr/bin/env ruby
    
    module DayLength
      def length
        if ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"].include? self
          "24 hours"
        else
          super
        end
      end
    end
    
    class String
      prepend DayLength
    end
    
    day = "Monday"
    
    x = day.length
    
    print(x)
    

  • paholg@lemm.eetoProgrammer Humor@programming.devExam Answer
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    8 months ago

    It could be Ruby; puts is more common, but there is a print. With some silly context, the answer could even be correct:

    #!/usr/bin/env ruby
    
    module DayLength
      def length
        if ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"].include? self
          "24 hours"
        else
          super
        end
      end
    end
    
    class String
      prepend DayLength
    end
    
    day = "Monday"
    
    x = day.length
    
    print(x)
    







  • paholg@lemm.eeto196@lemmy.blahaj.zoneLet them eat cereal rule
    link
    fedilink
    English
    arrow-up
    12
    ·
    edit-2
    9 months ago

    Thanks for assuming a ton there, asshole.

    I have been there. I have scraped together coins I could find to buy a single pound of dry pasta, to eat it plain. Repeatedly.

    Money is not such an issue for me these days, but depression is. I know how hard it can be to do the minimal steps to make food.

    I understand how precious time, money, and energy can be. I have eaten cereal and the like for plenty of meals I shouldn’t have, and have always regretted it.

    There are better options.

    A $20 rice cooker is the same as like 5 boxes of cereal. If you are too money pressed, but have some time, one can likely be found nearly free at a thrift store or yard sale, or you can cook rice or pasta in a pot instead.

    If you don’t have access to a cooking surface, we’re getting to houselessness territory, which is a huge problem and is affecting far too many people, but is beyond just being poor or not having time.

    Edit: And if all that is too much, you can eat cold beans from a can. I have done this as well. It’s not great, but it’s a better option than cereal still.