Skip Navigation

Posts
1
Comments
283
Joined
2 yr. ago

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

Sometimes in German, sometimes in English.

  • 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:

     ruby
        
    # 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:

     ruby
        
    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.

  • Ruby has it as well:

     ruby
        
    a ||= b
    
    # which means
    a = a || b
    # wich is the same as
    a = b if !a
    # which rubyists like to write as
    a = b unless a
    # or as ternary
    a = a ? a : b
    
      
  • I don't see it ;(

  • Honest question: what else can they do anyway? They cannot fight this war alone.

  • Vielleicht könnte Trump diesen Gardisten noch einen schmissigen Namen geben. Zum Beispiel Hilfspolizei.

  • Kein Rückhoch kein Mitleid!

  • Everyone makes errors, but not everyone reflects and learns from them. I feel like that the Ubuntu team(?) did the right thing here.

  • badass

    Jump
  • ich_iel

    Jump
  • Stimmer.. Oh Gott das hat gedauert

  • Wait what? Tab groups? Didn't knew that!

  • Little bit disappointed that its not

    Arch

  • Please mark this as NSFW ( not safe for Windows)

  • Deleted

    Permanently Deleted

    Jump
  • Where did you get this information from?

  • Title

    Jump
  • I mean a bow kind of sits in top of your shirt. So it should be

     
        
     
    <°√}
      \ \
       \ \
        \ \
        { = }
       /\   /\
    
      
  • Wird dann die Luft außen angesaugt oder wie läuft das? Wenn man widerliche Dauerraucher als Nachbar hat, vermutlich keine gut Idee fürchte ich, oder?

  • Isn't this the best place? A shit post?

  • Drivers and damaging public property, name a more iconic duo