Campfyre
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Cipherd@lemmy.ml to Programmer Humor@lemmy.ml · 3 个月前

functions

lemmy.ml

message-square
37
fedilink
  • cross-posted to:
  • [email protected]
269

functions

lemmy.ml

Cipherd@lemmy.ml to Programmer Humor@lemmy.ml · 3 个月前
message-square
37
fedilink
  • cross-posted to:
  • [email protected]
alert-triangle
You must log in or # to comment.
  • potatoguy@lemmy.eco.br
    link
    fedilink
    arrow-up
    39
    arrow-down
    1
    ·
    3 个月前

    And the best:

    public static void () {}

    spoiler

    /s

    • Baizey@feddit.dk
      link
      fedilink
      arrow-up
      4
      ·
      3 个月前

      Technically java would also be (){} since the modifiers are optional (outside of public static void main(String… args)) and return type is ignore for the others :D

      • potatoguy@lemmy.eco.br
        link
        fedilink
        arrow-up
        6
        ·
        3 个月前

        Yeah, it’s a joke, but I disagree on the void, the other languages on the meme doesn’t need a return type (when they are returning nothing), java needs it.

  • Ŝan • 𐑖ƨɤ@piefed.zip
    link
    fedilink
    English
    arrow-up
    29
    ·
    3 个月前

    :(){:|: &};:

    • bleistift2@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      12
      ·
      3 个月前
      :(){:|: &};:
      :(){:|: &};:
      
      • HumanPerson@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        9
        ·
        edit-2
        3 个月前
        :(){:|: &};:
        :(){:|: &};:
        :(){:|: &};:
        :(){:|: &};:
        
        • cryoistalline@lemmy.ml
          link
          fedilink
          arrow-up
          7
          ·
          3 个月前
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          
          • somerandomperson@lemmy.dbzer0.com
            link
            fedilink
            arrow-up
            1
            ·
            2 个月前
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            :(){:|: &};:
            
  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    14
    ·
    3 个月前

    Bash fucks me up so much, too. You just put the parentheses there to say that something is a function, not for actually declaring the parameters that can be passed in…

    • vala@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      2
      ·
      3 个月前

      This really sends me

    • tetris11@feddit.uk
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 个月前

      |{}

  • KSP Atlas@sopuli.xyz
    link
    fedilink
    arrow-up
    13
    ·
    3 个月前

    Haskell: =

    • codemankey@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 个月前

      The language of the gods

  • bleistift2@sopuli.xyz
    link
    fedilink
    arrow-up
    12
    ·
    3 个月前
    function() {}
    
    • davel [he/him]@lemmy.ml
      link
      fedilink
      English
      arrow-up
      13
      arrow-down
      1
      ·
      3 个月前

      JavaScript can do better than that:

      () => {}
      
      • Oriel Jutty :hhHHHAAAH:@infosec.exchange
        link
        fedilink
        arrow-up
        5
        ·
        3 个月前

        C++: [](){}

        • davel [he/him]@lemmy.ml
          link
          fedilink
          English
          arrow-up
          4
          ·
          edit-2
          3 个月前

          Huh, I haven’t looked at C++ in decades, and I didn’t know they’d added lambda functions/expressions, in C++11. Apparently you can shorten it further: []{}

      • bleistift2@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 个月前

        The intention was to provide a longer version for the first step of the ladder.

  • davel [he/him]@lemmy.ml
    link
    fedilink
    English
    arrow-up
    8
    ·
    3 个月前

    Some Lisp dialects: (λ () )

    • tetris11@feddit.uk
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 个月前

      your IDE is hiding 6 characters there

      • davel [he/him]@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        3 个月前

        Some Lisps will accept a literal Unicode lambda character.

  • benagain@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 个月前

    They could have put php up the top where it belongs.

  • The_Hideous_Orgalorg@sh.itjust.works
    link
    fedilink
    arrow-up
    4
    ·
    3 个月前

    Remember kids:

    public void doFun();

    • tetris11@feddit.uk
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 个月前

      Teacher, I just voided myself in public, are we having fun?

  • Captain Aggravated@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    3 个月前

    Python: def :

    derpface.jpg

    • dreadbeef@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      edit-2
      3 个月前

      that’s a class method but a function tho

      • Captain Aggravated@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        3
        ·
        3 个月前

        AFAIK the syntax seems to be the same.

        def sayHam():
            print("Ham")
        
        sayHam()
        

        works when typed into the Python console, no class needed. I program as a hobby, I’m no expert on the language, but does Python even differentiate between functions and class methods internally? Other than just scope? There’s a possibility I’ll learn something today.

        • dreadbeef@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          1
          ·
          3 个月前

          I thought python was one of those weird OOP languages like Java or C# that bound all classless methods to some universal static class but im wrong on that.

          They are out there though so be on the lookout for these languages that doesnt believe in algebra.

          • Captain Aggravated@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            1
            ·
            3 个月前

            If you want to do anything of any scale with Python, you need to understand OOP because that’s how modules work, but you can use it without.

        • Uairhahs@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          3 个月前

          Nope Def is universal for definition of a function wether it be a class method main method or even nested method

  • Echo5@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    3 个月前

    Idk much about programming but that looks like a beautiful reduction of bloat in coding language 😶

  • bort@sopuli.xyz
    link
    fedilink
    arrow-up
    1
    ·
    3 个月前

    kotlin also has ()->{} and {} (when there is just 1 parameter)

  • somerandomperson@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    1
    ·
    3 个月前
    function "f" {}
    

    :/

  • HiddenLayer555@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    3 个月前

    I don’t use any but I’m sure there are functional languages where () is a function.

    • chaos@beehaw.org
      link
      fedilink
      arrow-up
      5
      ·
      3 个月前

      In Haskell, that’s “unit” or the empty tuple. It’s basically an object with no contents, behavior, or particular meaning, useful for representing “nothing”. It’s a solid thing that is never a surprise, unlike undefined or other languages’ nulls, which are holes in the language or errors waiting to happen.

      You might argue that it’s a value and not a function, but Haskell doesn’t really differentiate the two anyway:

      value :: String
      value = "I'm always this string!"
      
      funkyFunc :: String -> String
      funkyFunc name = "Rock on, "++name++", rock on!"
      

      Is value a value, or is it a function that takes no arguments? There’s not really a difference, Haskell handles them both the same way: by lazily replacing anything matching the pattern on the left side of the equation with the right side of the equation at runtime.

      • anton@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        1
        ·
        3 个月前

        Mostly a great comment, but I wouldn’t compare unit to null, it’s more like the void type.

  • Prunebutt@slrpnk.net
    link
    fedilink
    arrow-up
    3
    arrow-down
    3
    ·
    3 个月前

    Nix:

    x:;

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

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]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

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

  • 17 users / day
  • 333 users / week
  • 1.07K users / month
  • 6.59K users / 6 months
  • 2 local subscribers
  • 41K subscribers
  • 1.47K Posts
  • 35.6K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org