lemmy.onlylans.io
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 18 天前

Modern Programming

lemmy.zip

message-square
77
fedilink
576

Modern Programming

lemmy.zip

Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 18 天前
message-square
77
fedilink
  • oni ᓚᘏᗢ@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    18 天前

    I love something = condition and result1 or result2 in lua

    • Randelung@lemmy.world
      link
      fedilink
      arrow-up
      10
      ·
      edit-2
      18 天前

      Python does that, too.

      https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not

      • SatyrSack@lemmy.sdf.org
        link
        fedilink
        arrow-up
        2
        arrow-down
        1
        ·
        18 天前

        Are you just referring to how Python uses the English and/or instead of the more common &&/||? I think what the user above you was talking about was Lua’s strange ternary syntax using and/or.

        • lime!@feddit.nu
          link
          fedilink
          English
          arrow-up
          6
          ·
          edit-2
          17 天前

          no, the linked table shows how python also returns the first non-falsey result of an a or b expression rather than just giving a boolean. it’s useful for initialising optional reference args:

          def foo(a: list = None)
              a = a or []
          

          works with and as well.

    • oni ᓚᘏᗢ@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      18 天前

      often I do a function called elvis XD with the next signature elvis(condition, res1, res2)

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 891 users / day
  • 3.56K users / week
  • 9.42K users / month
  • 19.6K users / 6 months
  • 1 local subscriber
  • 24.6K subscribers
  • 1.54K Posts
  • 56.5K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org