Cult I Mean Group
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Cipherd@lemmy.ml to Programmer Humor@lemmy.ml · 3 days ago

functions

lemmy.ml

message-square
33
fedilink
268

functions

lemmy.ml

Cipherd@lemmy.ml to Programmer Humor@lemmy.ml · 3 days ago
message-square
33
fedilink
alert-triangle
You must log in or register to comment.
  • Captain Aggravated@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 days ago

    Python: def :

    derpface.jpg

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

      that’s a class method not a function tho

      • Captain Aggravated@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 day 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.

        • Uairhahs@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          1 day ago

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

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

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

  • Echo5@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

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

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    14
    ·
    2 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
      3
      ·
      2 days ago

      This really sends me

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

      |{}

  • potatoguy@lemmy.eco.br
    link
    fedilink
    arrow-up
    39
    arrow-down
    1
    ·
    3 days ago

    And the best:

    public static void () {}

    spoiler

    /s

    • Baizey@feddit.dk
      link
      fedilink
      arrow-up
      4
      ·
      3 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
        ·
        3 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
    ·
    3 days ago

    :(){:|: &};:

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

    Haskell: =

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

      The language of the gods

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

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

    • chaos@beehaw.org
      link
      fedilink
      arrow-up
      5
      ·
      2 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
        ·
        24 hours ago

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

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

    Remember kids:

    public void doFun();

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

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

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

      JavaScript can do better than that:

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

        C++: [](){}

        • davel [he/him]@lemmy.ml
          link
          fedilink
          English
          arrow-up
          4
          ·
          edit-2
          3 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
        ·
        3 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
    9
    ·
    3 days ago

    Some Lisp dialects: (λ () )

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

      your IDE is hiding 6 characters there

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

        Some Lisps will accept a literal Unicode lambda character.

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

    Nix:

    x:;

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

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

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: !programmerhumor@lemmy.ml

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.

  • 127 users / day
  • 1.17K users / week
  • 2.56K users / month
  • 7.53K users / 6 months
  • 1 local subscriber
  • 39.2K subscribers
  • 1.92K Posts
  • 36.6K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org