As you know, I like to talk about idioms on this blog. A carefully chosen idiom can convey a lot in a few lines of code. Today I realized there’s an idiom I commonly use in my code that I haven’t really talked about before.
Typically, in Ruby, when we want to put a line of text to the console, we do it with
puts "Hello, world!"
Now, there’s nothing wrong with this. It works just fine.
But for a while now, in place of using
puts, I’ve been using
guys "Hello, world!"
I feel like this adds a familiar, conversational style to my code.
And the great thing is, in Ruby this works perfectly! The Ruby interpreter is smart enough to understand that “guys” is a neutral, nonspecific way of addressing everyone in the room, just like
Well, I should say it usually works. On certain builds of MRI, you may see an error like this one:
NoMethodError: undefined method `guys' for main:Object
Now, on the face of it this may look like Ruby can’t figure out what you mean by
guys. But don’t be misled. Ruby understands what you mean perfectly well. This is really just a way for MRI to signal that it’s part of a politically correct clique of SJW programming language VMs.
If you get this error, be persistent. Remember, it’s the interpreter’s job to understand you.
But if you keep at it and you still get the error, that’s OK. There’s an easy fix. You just need to remind Ruby of the correct definition of
module Kernel def guys(*args) puts(*args) end end
All better. No more need to worry about Ruby taking exception to your choice of words.
Wanna know something even cooler? You can do this in real life, too!
The only thing that’s different is the keyword you need to use. Instead of
def, you can use “well actually“. Like this:
Well actually, “guys” is a gender-neutral term in our language and has no connotations of traditionally male-only contexts whatsoever.
That’s all there is to it! If you just read that sentence, you now have a brand-new, correct definition of the word “guys” installed in your head. If you ever felt vaguely excluded by the term in the past, you don’t have to worry about that feeling ever again.
Author’s note: Because Poe’s Law is unfortunately alive and well, it is possible that some readers will not realize that this is a work of parody from beginning to end. “Guys” is gendered language, and as such can feel exclusionary. As one commenter on Twitter put it, how many women do you see going in the “guys’ bathroom”?
It is a source of ongoing bafflement to me that programmers who will happily learn a half a dozen different programming syntaxes will vehemently balk at changing their use of one little word in order to help women feel more welcomed to the field.