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

Programmer Humor

19331 readers
20 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 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] hydroptic@sopuli.xyz 33 points 6 months ago (10 children)

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 15 points 6 months ago* (last edited 6 months ago) (9 children)

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);
    }
[–] noproblemmy@programming.dev 1 points 6 months ago (1 children)

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

[–] Karyoplasma@discuss.tchncs.de 1 points 6 months ago

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

load more comments (7 replies)
load more comments (7 replies)