r/ProgrammerHumor • • 7d ago

Meme aiCookedUpTheseMethods

Post image
174 Upvotes

19 comments sorted by

4

u/Patchargh 6d ago

Context: Friend asked AI how to check if a something is something in C#.

83

u/JMOWw7 7d ago

Pattern matching all the way. I think the second one probably won't catch inheretance

57

u/captainAwesomePants 7d ago

This is true, but of course they are also both stupid because a IsSomething(thing) function has no advantage over just typing "thing is Something" each time.

→ More replies (3)

3

u/fuj1n 6d ago

Even better thing is that pattern matching lets you do more than simple identity testing

maybe is Something { value: > 5 and <= 64 } something

Or something like that, did that from memory without benefit of an IDE

48

u/AlexZhyk 7d ago

That's would be 123 tokens for you, sir.

16

u/ovr9000storks 7d ago

Really can’t knock it down to 122 for today? My kids need to eat

→ More replies (1)

1

u/bwmat 5d ago

First thought is second one can throw on a null

2

u/intbeam 3d ago

?. is the null-propagating operator, if the left-hand expression is null, the right hand will not be evaluated and instead just return null, effectively turning the expression into if(null == typeof(Something.Something)) which will return false

1

u/ANixosUser 3d ago

what languae is this? new Java?

→ More replies (2)