397
You wouldn’t get it (sh.itjust.works)
you are viewing a single comment's thread
view the rest of the comments
[-] hydroptic@sopuli.xyz 34 points 8 months ago

Where are your gods now?

public static Joke getTheJoke(Meme yourMeme) {
  Field jokeField = Meme.class.getDeclaredField("joke");
  jokeField.setAccessible(true);
  return (Joke) jokeField.get(yourMeme);
}
[-] RonSijm@programming.dev 16 points 8 months ago* (last edited 8 months ago)

Is it Java? It looked like ~~Microsoft Java~~ C# to me...

    public static void Main(string[] args)
    {
        var meme = new Meme();
        var joke = GetTheJoke(meme);
    }
    
    public static Joke GetTheJoke(Meme theMeme)
    {
        var memeType = typeof(Meme);
        var jokeField = memeType.GetField("Joke", BindingFlags.NonPublic | BindingFlags.Instance);
        return (Joke)jokeField.GetValue(theMeme);
    }
[-] PoolloverNathan@programming.dev 4 points 8 months ago

There isn't an unnecessary level of capitalization; seems to be regular Java with Allman braces.

[-] hydroptic@sopuli.xyz 3 points 8 months ago

Frankly it's been a while since I wrote either one. I just assumed Java because of the naming convention, and I didn't see anything I took as obviously un-Java in the class definition

[-] rimjob_rainer@discuss.tchncs.de 2 points 8 months ago

Because C# is a Java clone

[-] noproblemmy@programming.dev 1 points 8 months ago

If you have to cast your joke it isn't funny?

[-] Karyoplasma@discuss.tchncs.de 1 points 8 months ago

Could just change it to public static Object GetTheJoke, no?

this post was submitted on 15 Apr 2024
397 points (91.6% liked)

Programmer Humor

19817 readers
623 users here now

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

founded 2 years ago
MODERATORS