Campfyre
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Cipherd@lemmy.ml to Programmer Humor@lemmy.ml · 11 days ago

functions

lemmy.ml

message-square
36
fedilink
  • cross-posted to:
  • [email protected]
263

functions

lemmy.ml

Cipherd@lemmy.ml to Programmer Humor@lemmy.ml · 11 days ago
message-square
36
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
    ·
    11 days ago

    And the best:

    public static void () {}

    spoiler

    /s

    • Baizey@feddit.dk
      link
      fedilink
      arrow-up
      4
      ·
      11 days ago

      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
        ·
        11 days ago

        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
    28
    ·
    11 days ago

    :(){:|: &};:

    • bleistift2@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      12
      ·
      11 days ago
      :(){:|: &};:
      :(){:|: &};:
      
      • HumanPerson@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        9
        ·
        edit-2
        11 days ago
        :(){:|: &};:
        :(){:|: &};:
        :(){:|: &};:
        :(){:|: &};:
        
        • cryoistalline@lemmy.ml
          link
          fedilink
          arrow-up
          7
          ·
          11 days ago
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          :(){:|: &};:
          
  • KSP Atlas@sopuli.xyz
    link
    fedilink
    arrow-up
    13
    ·
    11 days ago

    Haskell: =

    • codemankey@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 days ago

      The language of the gods

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    13
    ·
    11 days ago

    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
      ·
      10 days ago

      This really sends me

    • tetris11@feddit.uk
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 days ago

      |{}

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

      JavaScript can do better than that:

      () => {}
      
      • Oriel Jutty :hhHHHAAAH:@infosec.exchange
        link
        fedilink
        arrow-up
        5
        ·
        11 days ago

        C++: [](){}

        • davel [he/him]@lemmy.ml
          link
          fedilink
          English
          arrow-up
          4
          ·
          edit-2
          11 days ago

          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
        ·
        11 days ago

        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
    ·
    11 days ago

    Some Lisp dialects: (λ () )

    • tetris11@feddit.uk
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 days ago

      your IDE is hiding 6 characters there

      • davel [he/him]@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        11 days ago

        Some Lisps will accept a literal Unicode lambda character.

  • The_Hideous_Orgalorg@sh.itjust.works
    link
    fedilink
    arrow-up
    4
    ·
    11 days ago

    Remember kids:

    public void doFun();

    • tetris11@feddit.uk
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 days ago

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

  • benagain@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    10 days ago

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

  • Captain Aggravated@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    10 days ago

    Python: def :

    derpface.jpg

    • dreadbeef@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      edit-2
      10 days ago

      that’s a class method but a function tho

      • Captain Aggravated@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        3
        ·
        10 days ago

        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
          ·
          8 days ago

          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
            ·
            8 days ago

            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
          ·
          10 days ago

          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
    ·
    10 days ago

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

  • somerandomperson@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    1
    ·
    10 days ago
    function "f" {}
    

    :/

  • HiddenLayer555@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    10 days ago

    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
      ·
      10 days ago

      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
        ·
        9 days ago

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

  • bort@sopuli.xyz
    link
    fedilink
    arrow-up
    1
    ·
    11 days ago

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

  • Prunebutt@slrpnk.net
    link
    fedilink
    arrow-up
    3
    arrow-down
    3
    ·
    11 days ago

    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
  • 31 users / week
  • 1.47K users / month
  • 6.59K users / 6 months
  • 2 local subscribers
  • 39.3K subscribers
  • 1.43K Posts
  • 35.4K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org