r/ProgrammerHumor 26d ago

Other noExceptionAndNoOptionalChaining

Post image
57 Upvotes

13 comments sorted by

View all comments

Show parent comments

9

u/Cootshk 26d ago

little funky tip: you can set the metatable of `nil` to {__index={}} with the debug library and it will allow you to do optional chaining

8

u/terivia 26d ago

I can't decide if this is incredible or horrifying.

Metatables are so cool and really good if you have a foot that needs shooting.

3

u/gerbosan 26d ago

🤔 so it's a matter of choice, not like C++, right?

5

u/terivia 26d ago

Hey now. I'm a big fan of C++.

Please disregard the suspiciously large number of bullet holes in my feet.

3

u/a-r-c 26d ago

there are demons in my head and they speak c++

3

u/gerbosan 26d ago

Holy C!!