Drew Bragg

Summarized using AI

Who Wants to be a Ruby Engineer?

Drew Bragg • February 28, 2023 • Providence, RI

Summary of "Who Wants to be a Ruby Engineer?"

The video features a lively game show centered around testing contestants' knowledge of Ruby programming. Hosted by Drew Bragg at RubyConf Mini 2022, the event aims to enlighten participants about the nuances and peculiarities of Ruby programming through engaging questions.

Key Points Discussed:

  • Introduction and Format of the Game Show: Drew Bragg welcomes attendees and outlines the game rules where contestants guess the output of various Ruby code snippets, assisted by multiple-choice options and audience participation.
  • Terminology and Syntax Clarification: Drew provides insights into Ruby programming language features, explaining the use of different operators, methods, and syntax through practical code examples.
  • Concepts of Valid Syntax: The show begins by addressing that most Ruby code presented is valid and can be executed, although some might be confusing or unconventional.
  • Interactive Contestant Participation: Contestants, including Aji, Elise, Mina, and Gary, face challenging Ruby code questions ranging from basic operations to more intricate Ruby concepts.
  • Learning through Mistakes: Drew encourages positive reinforcement, stating that wrong answers provide learning opportunities, fostering a supportive environment during the game.
  • Audience Engagement: The audience plays a significant role, helping contestants answer questions and fostering an interactive atmosphere. They are encouraged to cheer for incorrect answers as they represent growth and learning.
  • Prizes and Sponsors: The game includes a competitive aspect with prizes sponsored by notable contributors to the Ruby community, emphasizing community support in the Ruby ecosystem.
  • Conclusion and Appreciation: As the game comes to an end, Drew thanks the contestants, sponsors, and organizers, reinforcing the humor and excitement surrounding learning Ruby. He invites attendees who enjoyed the session to connect with him for more weird Ruby content.

Takeaways:

  • Engaging with Ruby's complexities can be fun and educational.
  • Community support plays a vital role in personal and professional growth for Ruby developers.
  • Mistakes in coding should be viewed positively as learning experiences. This game show format not only entertains but also enhances awareness of Ruby, showcasing its quirks and capabilities, thus motivating developers of all levels to dive deeper into the language.

Who Wants to be a Ruby Engineer?
Drew Bragg • February 28, 2023 • Providence, RI

Welcome to the Ruby game show where one lucky contestant tries to guess the output of a small bit of Ruby code. Sound easy? Here's the challenge: the snippets come from some of the weirdest parts of the Ruby language. The questions aren't easy. Get enough right to be crowned a (some sort of something) Ruby Engineer and win a fabulous, mysterious prize.

RubyConf 2022 Mini

00:00:00.299 Welcome to "Who Wants to be a Ruby Engineer?" This is the only Ruby game show here at RubyConf Mini. I am your host, Drew Bragg. Contrary to popular belief, I am from Philadelphia, not Oklahoma.
00:00:06.679 I am a staff engineer at a company called Within3 and the host of a podcast called "Coders Who Code." You can find me on most social media platforms at DrBragg, which has two G's. Speaking of my company, we are hiring! If you are a Ruby on Rails engineer looking for an exciting role doing interesting and occasionally complex work, please come and see me or any of the other awesome Within3 engineers here. Lindsey Kelly gave an incredible talk on the first day, and Jordan, Dan, Kevin, and Lynn, along with another Lindsey, are all also here. We would love to talk to you about how great it is to work at Within3.
00:00:35.820 Before we get started with the fun, I have a little disclaimer: most of the Ruby you are about to see is valid syntax and will run. You can use it to confuse and bewilder your coworkers, which can be fun, but not in production code. Instead, you can use it to gain a better understanding of Ruby and how it works—but please, do not commit it to your production app. Think very carefully before you commit! I like keeping Ruby weird. I like keeping Ruby fun, but I also like keeping Ruby readable.
00:01:12.060 So here's how today will go: I apologize if my slides are hard to read, but that’s due to the font size. I have some wonderful contestants here in the front row. They will come up one at a time and will have about 20 seconds to guess the output of a small snippet of Ruby code. I'm not a monster, they'll have multiple choices: A, B, C, or D. I didn’t have those choices when I was trying to figure out what the heck was going on when I saw the code the first time. They will also have some powers they can use: they can ask one of you to answer for them, or they can search Stack Overflow. We’ll take a poll to see what everyone thinks is the right answer.
00:01:53.460 If a contestant gets it wrong, they’ll sit down, and we'll have the next contestant come up. Nobody should feel bad about getting them wrong; these questions are practically designed to be difficult. You should actually feel happy when you get it wrong because it means you learned something! So, when a contestant does get a question wrong, let's give them a round of applause because we all just learned something.
00:02:33.220 That being said, I do have some prizes, and in the spirit of competition like in a game show, the better you do, the first crack you get at the prizes. Those prizes are made possible thanks to our sponsors, Joe Masolati and Rails Dev, who provided a bulk of these prizes. If you do not know Joe, he is a fantastic human being and doing a ton of work to help Ruby and Rails juniors get hired. Rails Dev is an open-source reverse job board specifically for Rails devs. He is also helping a lot of people get their first open source commit to Rails Devs and aiding them in finding jobs. If you haven’t met Joe yet, please go out of your way to meet him and thank him for all he does for our community.
00:03:13.800 Another sponsor I have is the one and only, Andrew Mason. Most of you know him from the Remote Ruby Podcast. He also does a podcast called "Ruby for All," which is wonderful and fantastic for juniors. Additionally, he runs the Ruby Radar newsletter with Colin Gilbert. Last but not least, we have the one and only Andy Kroll right here. Everyone, please give Andy a round of applause—not just for sponsoring this game show, but also for helping so much in putting this on.
00:03:43.320 Now, I have to ask: who wants to be a Ruby engineer? Who is my first contestant?
00:04:04.560 As soon as you are ready, please introduce yourself to us, tell us where you're from, and how long you've been working with Ruby.
00:04:53.060 Sure, my name is Aji. I am from Chicago and work at Thoughtbot. I think I'm coming up on my third anniversary of being a professional Ruby dev because I started on Leap Day in 2016.
00:05:05.220 Awesome! This first question won't count against you. If you get it wrong, you can still stay up; it’s just a warm-up question so that everyone in the audience, yourself included, and the other contestants know how the game will work. So, I apologize again if this syntax is hard to read, but please bear with me.
00:05:45.180 Aji, you're going to take a look at this short snippet of Ruby: "1 double colon + (2)". Do you think that this will return A) 3, B) a NoMethodError, C) 12, or D) a syntax error? What do you think?
00:06:41.880 B, NoMethodError?
00:06:52.680 Actually, you are correct! It will return a 3.
00:07:05.280 For those of you who are confused, the double colon is a namespace resolution operator. It helps us go from modules into classes and can also be used to call instance methods. Since one is the instance of an integer, it has an instance method called + that accepts an argument. What we just saw is equivalent to sending "+ (2)" to "1", or commonly, "1 + 2". For the love of math, please use "1 + 2." Make your code readable.
00:07:32.400 Now we're going to start the real game! Here is a short snippet of Ruby: We have the string "f", and we are going to ask it in a predicate method with the range of "a" through "z". Are we going to get back A) true, B) false, C) nil, or D) raise a NoMethodError? It feels like it could be a trick.
00:08:05.160 Aji, if you think it's going to be a trick, let's ask Stack Overflow! Show of hands, who thinks it's going to be A) true? A decent amount. B) false? No one. C) nil? One person. Or D) a NoMethodError? 50/50 split between A and D. Aji, what’s your final answer?
00:09:00.900 I'm going to go with D) a NoMethodError.
00:09:40.140 And you are correct! For those of you who answered A and are scratching your heads, this method "in" is actually provided by Active Support in Rails; it's not part of Ruby itself. Great work!
00:10:16.020 Next question: we have an instance variable "this" set to the string "fun". We are going to interpolate it into double quotes with "this is %{this}". What do you think this will return? A) a syntax error, B) the string "this is fun", C) the literal string "this is %{this}", or D) a name error?
00:10:53.320 I'm going to say it's C.
00:11:20.760 So close, but actually, this works! I found this out because I made a typo and was very confused about how this worked. It turns out that when you're interpolating instance or class variables, you can omit the curly braces completely, and interpolation will work just fine.
00:11:55.860 Thank you very much for playing! Can we have our next contestant, please?
00:12:04.020 If you could introduce yourself, tell us where you're from, and how long you've been working with Ruby.
00:12:15.780 Absolutely! I'm Elise, living in Colorado but originally from Pennsylvania. I have been doing Ruby since 2010.
00:12:33.540 Are you ready to play 'Who Wants to be a Ruby Engineer'?
00:13:00.780 Sure, yes. No, I hope so. Let's do it.
00:13:21.840 We have a variable "str" set to an empty string, and we're going to shovel in the integer "97" and then print out "str". Is this going to give us A) a type error, B) the string "97", C) the string "a", or D) the integer "97"?
00:14:25.380 Uh, so I think it will give us B.
00:15:15.120 Actually, it will give us C. You see, when you shovel in an integer, it treats it like a code point and converts it into the ASCII compatible character.
00:15:32.760 Now, can we have our next contestant, please?
00:16:04.200 Same thing, introduce yourself, where you're from, and how long you've been doing Ruby.
00:16:11.640 I'm Mina, I’m from Chicago, and I've been doing Ruby for four and a half years.
00:16:33.840 Great! Are you ready to play?
00:16:42.840 No, but we can do it anyway!
00:17:04.120 Alright, we have an array with the integers 1, 2, and 3. If we multiply it by 2, is that going to give us A) an array with 2, 4, 6; B) an array with 1, 2, 3, 1, 2, 3; C) an array of arrays with 1, 2, 3 in each; or D) raise a syntax error?
00:17:30.000 I don't think it's A, but I want to pair with a friend! Alright, who do you want to pair with?
00:18:18.600 Joelle! Cheating Joelle, what do you think it is?
00:18:55.920 I believe in you!
00:19:07.600 We're going with B.
00:19:20.360 Actually, it’s A. What happens with multiplication when it's an integer is it behaves like concatenating the argument copies of that array.
00:19:40.760 Thank you for teaching me that! Who is my next contestant?
00:19:53.920 Let’s make this a little easier. Since we’re ripping through contestants, we’ll use the same method.
00:20:04.720 Once again, we have the array [1, 2, 3], and we’re going to multiply it by a string of '-' (a minus sign). What do you think this will give us?
00:20:21.760 A) an array with the strings "1-2-3"; B) an array with the strings "-1-2-3"; C) an array with negative 1, 2, 3; or D) the string "1 2 3"?
00:20:49.680 I would recommend Stack Overflow because it sounds like there's a lot of people talking about it. I think I'm going to go with Stack Overflow.
00:21:20.760 Alright, audience participation time! Who thinks it's A?
00:21:38.160 A couple of people. B? Slightly less people. C? Not zero people. D? Whoa, a lot of people!
00:21:56.760 You know what? I was thinking D anyway!
00:22:15.240 And you are correct! Even though that is the same method call, when the argument is a string instead of an integer, it operates like a join.
00:22:36.240 So, are you ready for your next question?
00:22:45.720 Yes, I think I am!
00:23:00.900 Alright, here we're defining a method called "how big?", which is a predicate and takes an argument of a hash. When we call size on that hash, what will we receive? A) 0, B) nil, C) an ArgumentError, or D) a NoMethodError?
00:23:45.700 I'm going to go out on a limb and say it'll raise a NoMethodError.
00:24:00.870 Actually, you were at least right that it would raise something. It's an ArgumentError because we are using curly braces. The interpreter thinks that’s a block.
00:24:35.020 Thank you very much for playing. I’m going to need another contestant!
00:25:10.290 Come on up! Go ahead and introduce yourself.
00:25:47.820 Hello! I’m Gary from Seattle, and I think this is about my second year working with Ruby.
00:26:13.020 What a great welcome! Sorry, Gary, I got a hard one for you, or at least I think it's hard. So we have a variable "foo" set to "Class.new". We then assign "name1" to "foo.name" and assign the constant "bar" to "foo.name". When we put those names out, what are we going to get?
00:26:42.240 A) nil and bar, B) foo and bar, C) class and class, or D) nil and nil?
00:27:10.560 I have no idea! Let’s ask Stack Overflow. What do we think? A) nil and bar?
00:27:35.760 There’s a couple of votes for B) foo and bar, no votes for C) class and class, okay, about the same amount as D) nil and nil.
00:28:24.120 Well, we know it has to be A or C, right? That’s what we just came up with.
00:28:58.680 I’m going to go with A: nil and bar.
00:29:04.280 An excellent guess! Joe got it correct. The module name returns nil if the module or class is anonymous, but the moment we assign it to a constant, it takes on that name. That's why we had nil followed by bar.
00:29:45.640 Ready for the next one?
00:29:59.920 Alright, here’s a fun one for you! We have a variable "nums", which is an empty array, and we’re going to go through each number from 1 to 10. If "i double equals 3" and "i double equals 8", if that evaluates to true, we will shovel "i" into nums, and then put nums out when we're done.
00:30:40.880 Is this going to give us: A) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10; B) 3 and 8; C) 1, 2, 9, 10; or D) 1, 2, 3, 4, 5, 6, 7, 8?
00:31:24.720 You still have your pair power!
00:32:01.960 I will pair!
00:32:15.840 You’re saying D?
00:32:43.560 Smart man! So, if you are as confused as I was when I saw this snippet, let me tell you, I couldn’t even Google it without looking up the term—it's called a flip-flop operator.
00:33:27.600 In short, when the first part of the conditional evaluates as true until the second part evaluates to true, that conditional remains true.
00:33:40.840 I know there are good uses for this; I just don’t know what they are. You can ask some of the experts.
00:34:00.480 Are you ready for your next question yet?
00:34:20.880 I'm somewhat prepared but do not have a lot of powers!
00:34:40.720 So we have an array with the question marks, and this code is going to operate. Are we going to get A) a name error; B) a string of question marks; C) a nil return; or D) the string question mark?
00:35:01.280 Everybody wants to know! I was initially thinking B, but that seems a little bit too straightforward. I’m going to go with D.
00:35:24.480 Actually, that’s unfortunately wrong. The answer is C. If you were to pull up IRB, assuming you have a new version of Ruby, it would return a single character-string.
00:35:41.920 Moving right along.
00:35:58.240 So we have 1 through 5, and we’re going to map over it. We’re going to send it ampersand with a colon and a minus. Are we getting back: A) 1, 2, 3, 4, 5 all negative; B) negative 1, 2, 3, 4, 5; C) no method error; or D) 1, 2, 3, 4?
00:36:30.040 What’s your answer?
00:37:07.600 I’m going to go with A.
00:37:35.960 And you are right! Nice work.
00:37:45.880 So, this is how the integer instance method for negatives work. The minus sign will return the integer negated. All three ways you see on the screen are all negative five—they are the same basic idea.
00:38:06.920 You should play the lottery after this!
00:38:30.760 Let’s talk about a situation where A is going to equal false or true and B is going to equal false or true. What will A and B return? Will it be: A) true and true; B) false and false; C) nil and true; or D) false?
00:39:33.000 You no longer have your power-ups!
00:39:48.030 I'm confused, but I want to go with A.
00:40:05.860 Unfortunately, it will evaluate to false and true. They do operate differently, and you were right that it has a lower precedence than the pipe. Good job, Gary, thank you very much for playing!
00:41:05.640 We need a new contestant!
00:41:20.180 A man that needs no introduction, but I'll let him do it anyway.
00:41:35.160 Hello! My name is Brandon Weaver. I'm currently in San Francisco, and I've been programming Ruby professionally for about 12 years. Interestingly, it’s been about 20 years actually, since RPG Maker XP had this lovely little RGSS thing, which is Ruby Game Script System, so I got to use that a long time ago.
00:42:18.970 Alright! Let’s find out! A is going to equal 3 times a block with the string "Ruby" in it. So is A going to return: A) Ruby, B) three times in a string; C) the integer 3; or D) an enumerator?
00:42:45.920 You're right, it's B.
00:43:05.440 For those of you who aren't Brandon, would you like to explain this?
00:43:29.280 Integer times returns an enumerator if there's no block provided, but in this case, we provided a block. However, the block just didn't do anything. What is returned is that integer.
00:43:45.760 Now, here is the next question! A is going to equal sleep 1.5. What will this yield: A) 1, B) nil, C) 2, or D) every time we call A, the system will sleep for 1.5 seconds?
00:44:09.200 I want to say B, but I'm going to do something controversial and say phone a friend to Sam.
00:44:34.600 I think it’s one or sometimes two. It depends on your system. Turns out sleep will actually return the amount of time it actually slept for.
00:45:00.240 But it's either going to be a one or two. So good job! I'm impressed!
00:45:22.600 Oh my God! I'm out of volunteers! Does anyone else want to come up here and try this?
00:46:13.760 Oh my god! Andy Kroll!
00:46:29.920 Hi! I'm Andy, nice to meet you. I've been programming Ruby since 2007.
00:46:42.720 Here’s your question: X is equal to X. What's X? Is it A) a name error, B) a system stack error, C) nil, or D) no method error?
00:47:26.240 Stack Overflow audience, what do you think? A name error?
00:47:47.560 A lot of agreement on that one. What’s it going to be? 1 and a half? We’ll go with one for now.
00:48:08.560 A very popular option.
00:48:32.000 So it looks like C is the winner.
00:48:58.440 So, if we just call X on its own, we will get that name error, but if we assign it to itself, it becomes nil.
00:49:20.440 Ready for the next question? No, but let’s go.
00:49:54.360 I’m not even going to read this. I'm just going to let you stare at it.
00:50:18.720 Are we going to get a name error? A nil error or the string question mark?
00:50:42.720 That's the string question mark because it would be D.
00:51:02.720 Are you sure? No, I'm not.
00:51:27.720 You have a partner to ask?
00:52:00.720 It is!
00:52:41.920 So, if you are scratching your head, think back a couple of years and remember that a question mark in a single character is returned.
00:52:58.720 Ready for the final question?
00:53:17.600 Yes, I can go at the end!
00:53:33.720 So we have: "deaf movie = deaf food [see]". What do you think foo plus foo’s going to be? A) nil; B) fubar; C) far; D) a syntax error?
00:54:05.920 So calling foo with a plus would be...
00:54:25.480 You can make your default parameters a method!
00:55:05.920 Let's give a huge round of applause for all of our contestants!
00:55:30.720 They did great! They actually got a few right! Please don't make your friends and colleagues' brains hurt.
00:56:03.480 I owe thanks to Ufuk and Kevin for all their help in putting this together. Ufuk gave me some evil ideas, and Kevin Murphy helped me with my CFP and calmed me down.
00:56:20.080 If you liked this kind of stuff, you can find me here! I will be happy to send you some weird stuff ideas.
00:56:46.480 If you liked this weird stuff and want to come work on some of it— the app here is 13 years old, written on Rails 2.0, and Ruby 1.8 by people who were writing PHP and C-sharp. It’s a lot of fun.
00:57:07.640 Thanks again, everyone. This was a blast!
Explore all talks recorded at RubyConf 2022 Mini
+33