Just a small frog hopping from post to post. Because it may be Wednesday my Dudes!

Sometimes in German, sometimes in English.

  • 0 Posts
  • 29 Comments
Joined 2 years ago
cake
Cake day: June 14th, 2023

help-circle




  • This is basically one of the core ideas of Ruby: that you can read it like a story. Once you are used to reading it as “do X unless Y”, you will miss it in other languages. Note that I wrote Y, not Y is true. Because often Y is a statement that has meaning in itself.

    Example:

    # imagine that given_name is some text from user input
    
    # this is of course valid:
    user.name = given_name if !user.is_locked
    
    # but this reads more fluently:
    user.name = given_name unless user.is_locked
    

    Ruby also allows using ? as last character in method names, which is a convention for methods that return either true or false.

    Same goes for ! (the bang operator), that is commonly used to tell developers that there exists a non-bang version of the same method as well. The bang method is often the more strict version (e.g. raises an error instead of returning nil; or having side effects compared to the non-bang version).

    So the above example may be more commonly written like this:

    user.name = given_name unless user.locked?
    

    and the question mark makes you automatically adding is or has while reading: Set the user’s name to the given_name unless the user is locked

    Of course this is all by convention and you may also do it different. But that’s how most Ruby code is written.

    To stay consistent, lots of projects use RuboCop, which warns you on inconsistency based on your project’s settings.














  • LeFrog@discuss.tchncs.detoADHD memes@lemmy.dbzer0.comCould be
    link
    fedilink
    English
    arrow-up
    15
    ·
    6 months ago

    It is like pooping: everyone does it, and everyone will sometimes experience diarrhoea and constipation. There may be days where you have to go twice because your stomach does not like you some time.

    But if I have to go to shit like 3 times a day every day, fighting against your rumbling cramping stomach because every time it is just watery deadly sewer pipe corroding stuff coming out of you, you should see a doctor.

    It is about frequency and amplitude of your symptoms. But there are also a lot of other syndroms and illnesses that may cause your issues. And never forget:

    A man can have as many diseases as he damn well pleases.

    Hickam’s dictum

    So keep in mind that having ADS does not mean there are no other conditions. There is actually a higher possibility to have something else as well (Comorbidity)