DEV Community

Cover image for What's The Last Question You Asked On StackOverflow?
B. Burt
B. Burt

Posted on

What's The Last Question You Asked On StackOverflow?

My last question was: What's =~ in Ruby?

And I was immediately down-voted ๐Ÿ˜„ Oh well. And now it looks like it's been deleted, probably because it was asked, and answered, here, and here.

For those wondering this is from Ruby docs:

=~ is Ruby's basic pattern-matching operator. When one operand is a regular expression and the other is a string then the regular expression is used as a pattern to match against the string. (This operator is equivalently defined by Regexp and String so the order of String and Regexp do not matter. Other classes may have different implementations of =~.) If a match is found, the operator returns index of first match in string, otherwise it returns nil.

Basically it's the pattern matching operator. Matches a regex with a string (or a string with a regex) and returns the position where the match starts. Or nil if no match. Or a TypeError if, say, you put the number 9 instead of a string. Or it could possibly return false, I think.

Did I mention I'm still a beginner? lol

My initial search for the meaning of =~ in Ruby, I found out later, came up fruitless because I had failed to include the keyword "operator" in my search. That's why I had missed those two relevant StackOverflow posts (and I think why I got down-voted).

So that you don't come up empty-handed on your next Google search,

Here are a few tips.

Some basics first: spelling doesn't matter (Google spell-checks) and capitalization doesn't matter (ruby is the same as Ruby).

Tip number 1: Choose words carefully.

Google says:

...try to choose words that are likely to appear on the site you're looking for. For example, instead of saying my head hurts, say headache...

Looking for how to pronounce a word?

Tip number 2: Put the word "define" in front of any word to get its definition.

Directly underneath the searched-for word will be a little speaker icon, click on it and out loud you will hear the correct pronunciation.

I used this after hearing more than one person say "integer" with a "g" sound, as in goose, instead of the "j" sound, as in jet, which is how I thought it was pronounced. I was right by the way. Integer is said with a "j" sound.

Although, the word "define" isn't strictly needed, I usually type the word by itself and the first result is the definition.

Tip number 3: Use quotation marks or parentheses to group words together.

This tells the search engine that you want results that include these particular words in this particular order.

Tip number 4: Use keywords, just like in programming.

You can use logic keywords like AND or NOT or OR. In Bing you can use operators like "|", "-" to exclude things and "&" as well as the words.

Tip number 5: Search within a certain domain or site or for a certain file-type.

For example, site:edu "ruby programming". You can include the dot, like, site:.gov or site:.org but don't use spaces around the colon though, site : youtube is a no-no.

You can search for only specific file-types, for example, ext:pdf "ruby books" In Bing it's filetype:pdf.

Y'all probably know all this stuff already, but did you know you can search for cached pages? I didn't.

Tip number 6: Search for cached sites.

Google offers the best help compared to other search engines (Ecosia, Bing, Yahoo, etc) when it comes to advanced search options.

When your search results pop up, next to the title of the search result, to the right, are three little dots. Click the dots and a little "About This Result" modal appears. At the bottom of that are buttons, and if there's a cached site available, click on the "Cached" button and you will get the most recent cached version of the site.

Or you can just put "cache" in front of your search term.

That's all, hope you liked it. I'll keep writing so for more stuff you probably already know ๐Ÿคช, follow me.

Top comments (3)

Collapse
 
jlee1546 profile image
Jonathan Lee

Ruby equals tilde

Sometimes just spelling out things helps tremendously. Good read!

Collapse
 
beeburrt profile image
B. Burt • Edited

These guys call it the equalike, lol. Cool site tho:

ruby-operators.herokuapp.com/equalike

by the way, I took your advice today when searching and spelled something out, totally worked better

Collapse
 
beeburrt profile image
B. Burt

Thanks! I heard someone say that it's the bacon cannon operator. lol