• 0 Posts
  • 45 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)
    







  • Why isn’t there a way for Linux users to automatically install every missing dependency for a program?

    There is; actually there are several. Every^* distribution has a package manager, that’s what it does. But you have to make a package for the program, similar to what the tegaki folks have done for Mac and Windows.

    Another option is to statically link everything.

    One issue is the fragmentation; because there are so many Linux distributions, it’s hard to support packages for all of them. This is one thing that flatpack aims to solve.

    I would expect this to be an issue for old closed-source software, but not for old free software. Usually there’s someone to maintain packages for it.

    Some cursory searching shows no tegaki package on flathub or in nix (either of these can be used on any distro; the nix one is surprising to me; it hosts soooo many packages).

    But I do see it in Debian: https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=tegaki