[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:25.56,0:00:27.98,Default,,0000,0000,0000,,All right, good morning people. Dialogue: 0,0:00:27.98,0:00:32.52,Default,,0000,0000,0000,,After a bright talk this morning by Ajey,\Nit's Dialogue: 0,0:00:32.52,0:00:37.93,Default,,0000,0000,0000,,time to get dark and dirty, OK. So I'm Dialogue: 0,0:00:37.93,0:00:42.19,Default,,0000,0000,0000,,from Josh Software, and it started in 2007.\NThese Dialogue: 0,0:00:42.19,0:00:47.10,Default,,0000,0000,0000,,are my Twitter handles. And I'm also an author. Dialogue: 0,0:00:47.10,0:00:50.04,Default,,0000,0000,0000,,I have a couple of books which are out. Dialogue: 0,0:00:50.04,0:00:53.72,Default,,0000,0000,0000,,Well it doesn't look so dark anymore, does\Nit? Dialogue: 0,0:00:53.72,0:00:57.75,Default,,0000,0000,0000,,So what is my talk gonna be about? Don't Dialogue: 0,0:00:57.75,0:01:01.61,Default,,0000,0000,0000,,worry. It's not gonna be anything scary. I\Nlove Dialogue: 0,0:01:01.61,0:01:06.57,Default,,0000,0000,0000,,Ruby. But as with every marriage, and I hope Dialogue: 0,0:01:06.57,0:01:09.15,Default,,0000,0000,0000,,there's no Ruby in the crowd - OK. As Dialogue: 0,0:01:09.15,0:01:11.17,Default,,0000,0000,0000,,with every marriage you also need to know\Nthe Dialogue: 0,0:01:11.17,0:01:14.05,Default,,0000,0000,0000,,other side. You know the side you were - Dialogue: 0,0:01:14.05,0:01:16.84,Default,,0000,0000,0000,,you didn't know when you were just going around. Dialogue: 0,0:01:16.84,0:01:19.99,Default,,0000,0000,0000,,But it's the same thing with Ruby. You have Dialogue: 0,0:01:19.99,0:01:22.88,Default,,0000,0000,0000,,to know what you're looking at. And my talk Dialogue: 0,0:01:22.88,0:01:25.84,Default,,0000,0000,0000,,is going to be about the weirdness and the Dialogue: 0,0:01:25.84,0:01:29.55,Default,,0000,0000,0000,,gotcha moments. In short, in my talk, if you Dialogue: 0,0:01:29.55,0:01:35.69,Default,,0000,0000,0000,,find 'Ah-ha!' moments, it's working. Oh, we\Nhave a Dialogue: 0,0:01:35.69,0:01:40.33,Default,,0000,0000,0000,,varied audience today. So to ensure sanity,\NI have Dialogue: 0,0:01:40.33,0:01:44.12,Default,,0000,0000,0000,,tagged my slides. My slides are tagged with\Nmy Dialogue: 0,0:01:44.12,0:01:48.92,Default,,0000,0000,0000,,good friend bumblebee to keep it neutral,\Nthat these Dialogue: 0,0:01:48.92,0:01:52.15,Default,,0000,0000,0000,,are for beginners. So you must pay attention.\NAnd Dialogue: 0,0:01:52.15,0:01:54.73,Default,,0000,0000,0000,,the experts, try to give the beginners a chance Dialogue: 0,0:01:54.73,0:01:58.99,Default,,0000,0000,0000,,to give the answer. And the experts, you know, Dialogue: 0,0:01:58.99,0:02:03.22,Default,,0000,0000,0000,,take your inspiration from Optimus Prime.\NAnd the beginners Dialogue: 0,0:02:03.22,0:02:05.79,Default,,0000,0000,0000,,can choose to tune out, but whatever you learn, Dialogue: 0,0:02:05.79,0:02:09.97,Default,,0000,0000,0000,,the better. So let's get started with the\Ninfamous Dialogue: 0,0:02:09.97,0:02:16.97,Default,,0000,0000,0000,,infinity. Now, we all know what infinity is,\Nright? Dialogue: 0,0:02:17.86,0:02:20.57,Default,,0000,0000,0000,,And since we are all programmers, obviously\Nwe should Dialogue: 0,0:02:20.57,0:02:23.83,Default,,0000,0000,0000,,know the answer to this one. What's the answer? Dialogue: 0,0:02:23.83,0:02:29.09,Default,,0000,0000,0000,,There are no surprises here. No surprises\Nthere. No Dialogue: 0,0:02:29.09,0:02:32.52,Default,,0000,0000,0000,,division by zero. We know this. What about,\Nwhat Dialogue: 0,0:02:32.52,0:02:39.52,Default,,0000,0000,0000,,about this? Oops. This actually works. So\Nwe know Dialogue: 0,0:02:40.00,0:02:43.87,Default,,0000,0000,0000,,that everything in Ruby is an object. So that Dialogue: 0,0:02:43.87,0:02:45.54,Default,,0000,0000,0000,,looks like a, that looks like a class. So Dialogue: 0,0:02:45.54,0:02:47.76,Default,,0000,0000,0000,,let's see what the hell that is anyway. If Dialogue: 0,0:02:47.76,0:02:50.17,Default,,0000,0000,0000,,you type this out, what do you think I Dialogue: 0,0:02:50.17,0:02:54.66,Default,,0000,0000,0000,,get? So... what's going on here? So infinity\Nis Dialogue: 0,0:02:54.66,0:02:57.23,Default,,0000,0000,0000,,a constant define in the float class. Where\Ndo Dialogue: 0,0:02:57.23,0:02:59.56,Default,,0000,0000,0000,,you see it, you don't see it there. I Dialogue: 0,0:02:59.56,0:03:01.99,Default,,0000,0000,0000,,can use this constant to form range comparisons.\NI Dialogue: 0,0:03:01.99,0:03:04.63,Default,,0000,0000,0000,,can use it with equality operators and stuff\Nlike Dialogue: 0,0:03:04.63,0:03:08.80,Default,,0000,0000,0000,,that. Imagine three equal to equal to infinity.\NBut Dialogue: 0,0:03:08.80,0:03:13.26,Default,,0000,0000,0000,,it works. Oh well. So. This is the way Dialogue: 0,0:03:13.26,0:03:15.83,Default,,0000,0000,0000,,I get people warmed up. Let's do something\Nwith Dialogue: 0,0:03:15.83,0:03:19.45,Default,,0000,0000,0000,,more of an adrenaline rush. Base conversions.\NIt's a Dialogue: 0,0:03:19.45,0:03:22.93,Default,,0000,0000,0000,,lot of fun. So what do you think is Dialogue: 0,0:03:22.93,0:03:27.47,Default,,0000,0000,0000,,the output of this particular thing? Now,\NI don't Dialogue: 0,0:03:27.47,0:03:29.64,Default,,0000,0000,0000,,want all the math geeks going to their calculators, Dialogue: 0,0:03:29.64,0:03:34.89,Default,,0000,0000,0000,,but essence is converting a number to a string Dialogue: 0,0:03:34.89,0:03:38.70,Default,,0000,0000,0000,,in the octal format. So again, no surprises.\NShould Dialogue: 0,0:03:38.70,0:03:45.47,Default,,0000,0000,0000,,be fine. But let's push the tempo. Now what? Dialogue: 0,0:03:45.47,0:03:51.06,Default,,0000,0000,0000,,That, actually works. The next time you are\Nreading Dialogue: 0,0:03:51.06,0:03:54.44,Default,,0000,0000,0000,,about, and you hear a name like getafix, ?? Dialogue: 0,0:03:54.44,0:03:59.00,Default,,0000,0000,0000,,(00:03:57:07). You know oblix, asterix. It\Nneed not be Dialogue: 0,0:03:59.00,0:04:04.62,Default,,0000,0000,0000,,a name, it could be a number. Well, now Dialogue: 0,0:04:04.62,0:04:11.62,Default,,0000,0000,0000,,what? Push the limits. Oops. So now if you Dialogue: 0,0:04:12.60,0:04:14.98,Default,,0000,0000,0000,,look at it a little logically, the radix as Dialogue: 0,0:04:14.98,0:04:17.72,Default,,0000,0000,0000,,a portion ?? (00:04:15:18) is supported only\Nin thirty-six, Dialogue: 0,0:04:17.72,0:04:20.86,Default,,0000,0000,0000,,because you have twenty-six alphabets and\Nten digits. So Dialogue: 0,0:04:20.86,0:04:21.83,Default,,0000,0000,0000,,it can go only up to a radix of Dialogue: 0,0:04:21.83,0:04:26.24,Default,,0000,0000,0000,,thirty-six. So if there are some innovators\Nout there, Dialogue: 0,0:04:26.24,0:04:30.37,Default,,0000,0000,0000,,who want to actually get a new alphabet into Dialogue: 0,0:04:30.37,0:04:32.94,Default,,0000,0000,0000,,the English dictionary, we could probably\Nhave a radix Dialogue: 0,0:04:32.94,0:04:39.94,Default,,0000,0000,0000,,of thirty-seven. OK. Let's move on to the\Nstar. Dialogue: 0,0:04:41.18,0:04:43.87,Default,,0000,0000,0000,,Not the rock star, but the star operator.\NAnd Dialogue: 0,0:04:43.87,0:04:46.18,Default,,0000,0000,0000,,to start with, let's see what it has to Dialogue: 0,0:04:46.18,0:04:50.15,Default,,0000,0000,0000,,do with Splat Expander. Oh boy, we see more Dialogue: 0,0:04:50.15,0:04:53.55,Default,,0000,0000,0000,,and more of Ruby code right now. So what Dialogue: 0,0:04:53.55,0:04:58.03,Default,,0000,0000,0000,,do you think is name and occupation here?\NAs Dialogue: 0,0:04:58.03,0:05:00.99,Default,,0000,0000,0000,,we can see we have a struct which takes, Dialogue: 0,0:05:00.99,0:05:05.12,Default,,0000,0000,0000,,which has two somethings, name and occupation,\Nand I Dialogue: 0,0:05:05.12,0:05:09.95,Default,,0000,0000,0000,,create an object off the struct. Now what\Ndo Dialogue: 0,0:05:09.95,0:05:15.16,Default,,0000,0000,0000,,we see? Nothing fancy. We're still good. Right?\NSo Dialogue: 0,0:05:15.16,0:05:17.58,Default,,0000,0000,0000,,the Splat Expander is actually taking my arguments\Nand Dialogue: 0,0:05:17.58,0:05:20.60,Default,,0000,0000,0000,,given me the right name and the right occupation. Dialogue: 0,0:05:20.60,0:05:21.95,Default,,0000,0000,0000,,But we don't do things like this, do we? Dialogue: 0,0:05:21.95,0:05:25.93,Default,,0000,0000,0000,,We usually - we are Rails programmers. We\Nwork Dialogue: 0,0:05:25.93,0:05:27.90,Default,,0000,0000,0000,,in Rails, so we usually have stuff like this. Dialogue: 0,0:05:27.90,0:05:31.64,Default,,0000,0000,0000,,We use keyword arguments. We all have keyword\Narguments Dialogue: 0,0:05:31.64,0:05:34.52,Default,,0000,0000,0000,,to initiate a class like this and stuff. What Dialogue: 0,0:05:34.52,0:05:41.52,Default,,0000,0000,0000,,is the output now? It's Optimus Prime, so,\Nthe Dialogue: 0,0:05:42.80,0:05:47.78,Default,,0000,0000,0000,,experts? What is name and occupation? Here\Nit's changed. Dialogue: 0,0:05:47.78,0:05:52.28,Default,,0000,0000,0000,,That's because the struct always has an array\Nof Dialogue: 0,0:05:52.28,0:05:54.80,Default,,0000,0000,0000,,arguments. It does not differentiate between\Nthis. This will Dialogue: 0,0:05:54.80,0:05:59.01,Default,,0000,0000,0000,,not work on a class. Well, let's get to Dialogue: 0,0:05:59.01,0:06:04.49,Default,,0000,0000,0000,,something more funny. What about this? How\Nmany here Dialogue: 0,0:06:04.49,0:06:07.89,Default,,0000,0000,0000,,have used this before? We know how to convert Dialogue: 0,0:06:07.89,0:06:09.73,Default,,0000,0000,0000,,an array into hash. How many of you have Dialogue: 0,0:06:09.73,0:06:13.59,Default,,0000,0000,0000,,used this notation before? All right-y, I\Nhave two Dialogue: 0,0:06:13.59,0:06:17.78,Default,,0000,0000,0000,,people in the audience. Excellent. What happens\Nnow? What Dialogue: 0,0:06:17.78,0:06:20.63,Default,,0000,0000,0000,,does this do? It actually converts to a hash. Dialogue: 0,0:06:20.63,0:06:23.73,Default,,0000,0000,0000,,And out of curiosity what if I add a Dialogue: 0,0:06:23.73,0:06:29.76,Default,,0000,0000,0000,,seventh element in the array? Error. No like,\Ndude, Dialogue: 0,0:06:29.76,0:06:31.07,Default,,0000,0000,0000,,I don't know what to do, what should I Dialogue: 0,0:06:31.07,0:06:34.33,Default,,0000,0000,0000,,do with the last one? Well, let's try some Dialogue: 0,0:06:34.33,0:06:37.80,Default,,0000,0000,0000,,more stars. Who all thinks that the output\Nof Dialogue: 0,0:06:37.80,0:06:43.46,Default,,0000,0000,0000,,this is gonna be three, six, and nine? Who Dialogue: 0,0:06:43.46,0:06:50.46,Default,,0000,0000,0000,,all think otherwise? What's the output? Awesome.\NAnd now? Dialogue: 0,0:06:52.20,0:06:59.20,Default,,0000,0000,0000,,That was easy wasn't it? Now what? String\N?? Dialogue: 0,0:07:03.37,0:07:08.31,Default,,0000,0000,0000,,(00:07:04:24). That's all actually works.\NAnd let's take it Dialogue: 0,0:07:08.31,0:07:11.19,Default,,0000,0000,0000,,to the next level. How many here know about Dialogue: 0,0:07:11.19,0:07:14.83,Default,,0000,0000,0000,,Stabby, Stabby proc? Here is a sample. So\Nthis Dialogue: 0,0:07:14.83,0:07:17.49,Default,,0000,0000,0000,,is a Stabby proc that we have which takes Dialogue: 0,0:07:17.49,0:07:21.75,Default,,0000,0000,0000,,- note we are still working with star. So Dialogue: 0,0:07:21.75,0:07:23.91,Default,,0000,0000,0000,,if I make an invocation ?? (00:07:23:07) to\Nthe Dialogue: 0,0:07:23.91,0:07:30.91,Default,,0000,0000,0000,,block like this, what is the output? Mumbling,\Nmumbling, Dialogue: 0,0:07:32.55,0:07:39.55,Default,,0000,0000,0000,,mumbling. It's five. And now you say, I knew Dialogue: 0,0:07:40.26,0:07:42.38,Default,,0000,0000,0000,,that. Right. So basically the short form for\Nthe Dialogue: 0,0:07:42.38,0:07:45.63,Default,,0000,0000,0000,,first, second last, last, and the rest of\Nthe Dialogue: 0,0:07:45.63,0:07:49.29,Default,,0000,0000,0000,,stuff is in the middle. Pretty helpful thing\Nto Dialogue: 0,0:07:49.29,0:07:52.05,Default,,0000,0000,0000,,know. This works on all. It not, it's just Dialogue: 0,0:07:52.05,0:07:54.00,Default,,0000,0000,0000,,not worked with the Stabby proc, it'll work\Nwith Dialogue: 0,0:07:54.00,0:07:58.18,Default,,0000,0000,0000,,Lambda, it'll work with a method, too. But,\Nas Dialogue: 0,0:07:58.18,0:08:00.93,Default,,0000,0000,0000,,with Ruby, and, if I'm supposed to be standing Dialogue: 0,0:08:00.93,0:08:03.87,Default,,0000,0000,0000,,here and I'm supposed to be lecturing you\Non Dialogue: 0,0:08:03.87,0:08:06.92,Default,,0000,0000,0000,,all this, I'm supposed to know my stuff. Lo Dialogue: 0,0:08:06.92,0:08:11.09,Default,,0000,0000,0000,,and behold, when I was trying these experiments,\NI Dialogue: 0,0:08:11.09,0:08:14.42,Default,,0000,0000,0000,,learned something new. What do you think is\Nthe Dialogue: 0,0:08:14.42,0:08:18.87,Default,,0000,0000,0000,,output of that? That actually works, and I\Nhave Dialogue: 0,0:08:18.87,0:08:22.29,Default,,0000,0000,0000,,freaking no idea how. So, well let's put in Dialogue: 0,0:08:22.29,0:08:24.77,Default,,0000,0000,0000,,the slide, and if I have somebody looking\Nexplain Dialogue: 0,0:08:24.77,0:08:27.15,Default,,0000,0000,0000,,to me how does that dot notation just work? Dialogue: 0,0:08:27.15,0:08:29.49,Default,,0000,0000,0000,,And it works only on this. It will not Dialogue: 0,0:08:29.49,0:08:31.59,Default,,0000,0000,0000,,work on a method obviously, right. But it\Nworks! Dialogue: 0,0:08:31.59,0:08:38.59,Default,,0000,0000,0000,,So, welcome to the weirdness of Ruby. Well.\NGetting Dialogue: 0,0:08:38.62,0:08:44.24,Default,,0000,0000,0000,,onto really complex stuff. Case statements.\NHow many of Dialogue: 0,0:08:44.24,0:08:45.60,Default,,0000,0000,0000,,you have - you all have used cases, right? Dialogue: 0,0:08:45.60,0:08:47.24,Default,,0000,0000,0000,,Case when and stuff like that. Why do you Dialogue: 0,0:08:47.24,0:08:50.06,Default,,0000,0000,0000,,think this works? And I've tried to make the Dialogue: 0,0:08:50.06,0:08:54.58,Default,,0000,0000,0000,,example as complex as possible. All right.\NIf Optimus Dialogue: 0,0:08:54.58,0:08:56.68,Default,,0000,0000,0000,,Prime doesn't do this who the hell else would, Dialogue: 0,0:08:56.68,0:09:03.68,Default,,0000,0000,0000,,right? So what is the output? It's pretty\Nobvious Dialogue: 0,0:09:04.30,0:09:06.32,Default,,0000,0000,0000,,that we have a multiple of three, because\Nnine Dialogue: 0,0:09:06.32,0:09:08.33,Default,,0000,0000,0000,,is a multiple of three, and yeah, because\Nwe Dialogue: 0,0:09:08.33,0:09:10.45,Default,,0000,0000,0000,,can all read in English and Ruby gives us Dialogue: 0,0:09:10.45,0:09:14.88,Default,,0000,0000,0000,,readable code. We know the output here, right?\NWell Dialogue: 0,0:09:14.88,0:09:17.87,Default,,0000,0000,0000,,it's true. You're absolutely right. Ruby's\Nnot that weird. Dialogue: 0,0:09:17.87,0:09:20.17,Default,,0000,0000,0000,,It'll give you the right answers. But my question Dialogue: 0,0:09:20.17,0:09:25.87,Default,,0000,0000,0000,,is: multiple_of is a method, right? It takes\None Dialogue: 0,0:09:25.87,0:09:30.43,Default,,0000,0000,0000,,parameter, which I have passed. How was it\Ncompared Dialogue: 0,0:09:30.43,0:09:37.43,Default,,0000,0000,0000,,with nine? Where did nine come into the picture? Dialogue: 0,0:09:39.54,0:09:43.61,Default,,0000,0000,0000,,Behind every case, behind every successful\Ncase, is a Dialogue: 0,0:09:43.61,0:09:46.79,Default,,0000,0000,0000,,case equality operator. So what actually happens\Nis that Dialogue: 0,0:09:46.79,0:09:50.48,Default,,0000,0000,0000,,that number nine is used with a case equality Dialogue: 0,0:09:50.48,0:09:54.84,Default,,0000,0000,0000,,operator. And that case equality operator\Nis an alias Dialogue: 0,0:09:54.84,0:09:58.38,Default,,0000,0000,0000,,to the proc call, which actually gets us our Dialogue: 0,0:09:58.38,0:10:02.97,Default,,0000,0000,0000,,output. Well. Though this seems pretty straightforward,\Nit has Dialogue: 0,0:10:02.97,0:10:08.55,Default,,0000,0000,0000,,just given me immense power. I can now manipulate Dialogue: 0,0:10:08.55,0:10:10.62,Default,,0000,0000,0000,,any way that I want a case equality operator Dialogue: 0,0:10:10.62,0:10:14.63,Default,,0000,0000,0000,,to work. Simply by over riding the equal to Dialogue: 0,0:10:14.63,0:10:16.24,Default,,0000,0000,0000,,equal to equal to method - the case equality Dialogue: 0,0:10:16.24,0:10:19.26,Default,,0000,0000,0000,,operator. And I am good to have any sort Dialogue: 0,0:10:19.26,0:10:21.61,Default,,0000,0000,0000,,of case comparisons that I want to make. I Dialogue: 0,0:10:21.61,0:10:24.33,Default,,0000,0000,0000,,don't care what happens, but it's my call\Nanymore, Dialogue: 0,0:10:24.33,0:10:28.08,Default,,0000,0000,0000,,right. Speaking of case equality operator,\Nlet's go to Dialogue: 0,0:10:28.08,0:10:30.27,Default,,0000,0000,0000,,equality. How many of you all know these symbols? Dialogue: 0,0:10:30.27,0:10:34.04,Default,,0000,0000,0000,,There are operators, an eql question mark,\Nand equal Dialogue: 0,0:10:34.04,0:10:41.04,Default,,0000,0000,0000,,question mark. Let's have some fun. Any takers?\NWho Dialogue: 0,0:10:43.43,0:10:46.46,Default,,0000,0000,0000,,all think the output is true? Who all think Dialogue: 0,0:10:46.46,0:10:50.17,Default,,0000,0000,0000,,the output is false? What happened to the\Nrest Dialogue: 0,0:10:50.17,0:10:55.36,Default,,0000,0000,0000,,of the people? Don't care. Don't care. That's\Nbad Dialogue: 0,0:10:55.36,0:10:56.95,Default,,0000,0000,0000,,for a conference. You know we just got a Dialogue: 0,0:10:56.95,0:10:58.23,Default,,0000,0000,0000,,huge lecture about participation! Again, who\Nall thinks it's Dialogue: 0,0:10:58.23,0:11:05.23,Default,,0000,0000,0000,,true? Who all think it's false? Why? Oh, come Dialogue: 0,0:11:05.48,0:11:09.38,Default,,0000,0000,0000,,on man, Ruby's gonna be really neat. Of course Dialogue: 0,0:11:09.38,0:11:14.52,Default,,0000,0000,0000,,it's true. Well, what do you think now? Anybody Dialogue: 0,0:11:14.52,0:11:18.94,Default,,0000,0000,0000,,think it's true? All right man. Stand up dude. Dialogue: 0,0:11:18.94,0:11:21.80,Default,,0000,0000,0000,,Please give him a welcome, because he's got\Nit Dialogue: 0,0:11:21.80,0:11:26.82,Default,,0000,0000,0000,,absolutely right. What the hell happened to\Nthe rest? Dialogue: 0,0:11:26.82,0:11:29.40,Default,,0000,0000,0000,,Dude, we just saw the slide before about case Dialogue: 0,0:11:29.40,0:11:31.72,Default,,0000,0000,0000,,equality. Are you telling me if you use that Dialogue: 0,0:11:31.72,0:11:34.79,Default,,0000,0000,0000,,in a when statement it's not gonna work? Of Dialogue: 0,0:11:34.79,0:11:39.73,Default,,0000,0000,0000,,course it's gonna work. You're just comparing\Nto one. Dialogue: 0,0:11:39.73,0:11:46.06,Default,,0000,0000,0000,,And... now what? True? How many people think\Nit's Dialogue: 0,0:11:46.06,0:11:52.26,Default,,0000,0000,0000,,true? How many people think it's false? Why?\NSo Dialogue: 0,0:11:52.26,0:11:54.21,Default,,0000,0000,0000,,people called false but thought it was true\Nbut Dialogue: 0,0:11:54.21,0:11:57.39,Default,,0000,0000,0000,,didn't want to answer. Well it's false, and\NI've Dialogue: 0,0:11:57.39,0:11:59.11,Default,,0000,0000,0000,,got you guys so motivated you don't want to Dialogue: 0,0:11:59.11,0:12:02.96,Default,,0000,0000,0000,,answer, right. Damn it. But this is actually\Nequality Dialogue: 0,0:12:02.96,0:12:05.68,Default,,0000,0000,0000,,by value. So the value returned by the object Dialogue: 0,0:12:05.68,0:12:08.72,Default,,0000,0000,0000,,is one, the value returned by the float is Dialogue: 0,0:12:08.72,0:12:14.43,Default,,0000,0000,0000,,a floating point one. It's completely different.\NNow what? Dialogue: 0,0:12:14.43,0:12:18.30,Default,,0000,0000,0000,,Now it's interesting. Why is it false? Somebody\Nsaid Dialogue: 0,0:12:18.30,0:12:25.30,Default,,0000,0000,0000,,very confidently, why is it false? Absolutely.\NNow here's Dialogue: 0,0:12:25.43,0:12:29.10,Default,,0000,0000,0000,,the weirdness. This stuff actually compares\Nthe object ID Dialogue: 0,0:12:29.10,0:12:30.83,Default,,0000,0000,0000,,of the two, and a integer and a float Dialogue: 0,0:12:30.83,0:12:34.67,Default,,0000,0000,0000,,would have two different object IDs. It's\Nobvious, right Dialogue: 0,0:12:34.67,0:12:40.04,Default,,0000,0000,0000,,fellas? So. Aiy aiy aiy, true false, what's\Nit Dialogue: 0,0:12:40.04,0:12:47.04,Default,,0000,0000,0000,,guys? There string 'a' and string 'a' are\Ntwo Dialogue: 0,0:12:47.24,0:12:52.33,Default,,0000,0000,0000,,different ruby objects. If I switch that two\Na Dialogue: 0,0:12:52.33,0:12:54.60,Default,,0000,0000,0000,,symbol - thank you that's where you go. So Dialogue: 0,0:12:54.60,0:13:00.76,Default,,0000,0000,0000,,with that, let's hit the jackpot. How many\Nof Dialogue: 0,0:13:00.76,0:13:03.49,Default,,0000,0000,0000,,you all know what curry is? It's a lot Dialogue: 0,0:13:03.49,0:13:06.41,Default,,0000,0000,0000,,of fun, a lot of fun. But to make Dialogue: 0,0:13:06.41,0:13:10.39,Default,,0000,0000,0000,,it funnier, I actually decided let's have\Nthe slot Dialogue: 0,0:13:10.39,0:13:13.94,Default,,0000,0000,0000,,machine get three pulls. And I wrote code\Nfor Dialogue: 0,0:13:13.94,0:13:17.37,Default,,0000,0000,0000,,it on my flight here, so I have no Dialogue: 0,0:13:17.37,0:13:20.16,Default,,0000,0000,0000,,idea whether that's correct or wrong, but\Nlike, we Dialogue: 0,0:13:20.16,0:13:23.58,Default,,0000,0000,0000,,know it seems a little weird though. I've\Ntried Dialogue: 0,0:13:23.58,0:13:26.58,Default,,0000,0000,0000,,to compare if all the three pulls are equal Dialogue: 0,0:13:26.58,0:13:31.73,Default,,0000,0000,0000,,and then I'm preparing some recipe with curry,\Nand Dialogue: 0,0:13:31.73,0:13:37.35,Default,,0000,0000,0000,,do you think it would work? It just looks Dialogue: 0,0:13:37.35,0:13:40.81,Default,,0000,0000,0000,,a little bit of weird code, but I shall Dialogue: 0,0:13:40.81,0:13:46.85,Default,,0000,0000,0000,,explain. So curry is a method in the proc Dialogue: 0,0:13:46.85,0:13:51.77,Default,,0000,0000,0000,,class which actually returns a lambda if all\Nthe Dialogue: 0,0:13:51.77,0:13:55.01,Default,,0000,0000,0000,,parameters are not fulfilled. So in this particular\Ncase, Dialogue: 0,0:13:55.01,0:13:57.79,Default,,0000,0000,0000,,I needed three parameters, X, Y, and Z, and Dialogue: 0,0:13:57.79,0:14:00.76,Default,,0000,0000,0000,,in the first statement, I passed only one.\NNote, Dialogue: 0,0:14:00.76,0:14:04.04,Default,,0000,0000,0000,,the invocation is in square brackets. It's\Ndifferent. And Dialogue: 0,0:14:04.04,0:14:06.72,Default,,0000,0000,0000,,it returns me a lambda, but other times when Dialogue: 0,0:14:06.72,0:14:09.42,Default,,0000,0000,0000,,all the parameters are actually fulfilled\Nin the second Dialogue: 0,0:14:09.42,0:14:13.42,Default,,0000,0000,0000,,statement, it actually evaluates the proc.\NNow if you Dialogue: 0,0:14:13.42,0:14:15.61,Default,,0000,0000,0000,,had to write the same code you would have Dialogue: 0,0:14:15.61,0:14:18.46,Default,,0000,0000,0000,,taken different types of input, weighted for\Nthe user Dialogue: 0,0:14:18.46,0:14:23.29,Default,,0000,0000,0000,,with (00:14:18:29) ...?? one, two, three,\Nand evaluated it. Dialogue: 0,0:14:23.29,0:14:24.92,Default,,0000,0000,0000,,You don't need to do that. And these things Dialogue: 0,0:14:24.92,0:14:31.92,Default,,0000,0000,0000,,can actually be very helpful. So curry away.\NSo! Dialogue: 0,0:14:34.30,0:14:41.30,Default,,0000,0000,0000,,So you think you can tell protected from private. Dialogue: 0,0:14:41.95,0:14:44.32,Default,,0000,0000,0000,,OK, I am not a - I'm a better Dialogue: 0,0:14:44.32,0:14:50.36,Default,,0000,0000,0000,,programmer than a singer. Right. Private methods.\NAll of Dialogue: 0,0:14:50.36,0:14:54.00,Default,,0000,0000,0000,,us have been taught since school, unfortunately,\Nthat private Dialogue: 0,0:14:54.00,0:14:58.74,Default,,0000,0000,0000,,methods are not inherited. Are they inherited?\NAs you Dialogue: 0,0:14:58.74,0:15:01.26,Default,,0000,0000,0000,,can see, foo is a private method. And I Dialogue: 0,0:15:01.26,0:15:02.91,Default,,0000,0000,0000,,ran out of creativity, so I just went to Dialogue: 0,0:15:02.91,0:15:06.06,Default,,0000,0000,0000,,the standard base type foo, blah blah blah\Nhere. Dialogue: 0,0:15:06.06,0:15:10.62,Default,,0000,0000,0000,,Is this going to work? All of us take Dialogue: 0,0:15:10.62,0:15:13.07,Default,,0000,0000,0000,,a lot of things for granted. How many of Dialogue: 0,0:15:13.07,0:15:14.42,Default,,0000,0000,0000,,you all knew this already, that private methods\Nare Dialogue: 0,0:15:14.42,0:15:18.50,Default,,0000,0000,0000,,inherited in Ruby? All right, OK, now I'm\Nscared. Dialogue: 0,0:15:18.50,0:15:21.16,Default,,0000,0000,0000,,How many of you all didn't know this? Don't Dialogue: 0,0:15:21.16,0:15:24.61,Default,,0000,0000,0000,,be shy, don't be shy. OK, so this is Dialogue: 0,0:15:24.61,0:15:28.08,Default,,0000,0000,0000,,actually one of the basic principles of where\NRuby Dialogue: 0,0:15:28.08,0:15:32.34,Default,,0000,0000,0000,,actually breaks traditional object oriented\Nconcepts. All private methods Dialogue: 0,0:15:32.34,0:15:36.70,Default,,0000,0000,0000,,are inherited. What? How many of you all have Dialogue: 0,0:15:36.70,0:15:41.86,Default,,0000,0000,0000,,seen this code before? Forget the Mongoid::Document\Nbut include? Dialogue: 0,0:15:41.86,0:15:46.03,Default,,0000,0000,0000,,Wait, come on. Everybody knows it! What is\Ninclude? Dialogue: 0,0:15:46.03,0:15:53.03,Default,,0000,0000,0000,,Is it a keyword? How many thought it was Dialogue: 0,0:15:53.14,0:15:55.12,Default,,0000,0000,0000,,a keyword? Oh it's like that, require or that Dialogue: 0,0:15:55.12,0:16:01.64,Default,,0000,0000,0000,,import in Java. Include is a private instance\Nmethod Dialogue: 0,0:16:01.64,0:16:07.50,Default,,0000,0000,0000,,defined in the class module. So while that\Nis Dialogue: 0,0:16:07.50,0:16:10.98,Default,,0000,0000,0000,,sinking in, it raises a basic question. All\Nprivate Dialogue: 0,0:16:10.98,0:16:17.98,Default,,0000,0000,0000,,methods are inherited. So what are protected\Nmethods? So Dialogue: 0,0:16:18.27,0:16:19.89,Default,,0000,0000,0000,,what about protected methods? So what's the\Ndifference between Dialogue: 0,0:16:19.89,0:16:23.09,Default,,0000,0000,0000,,private methods and protected methods now?\NWe were told Dialogue: 0,0:16:23.09,0:16:27.29,Default,,0000,0000,0000,,in our school that protected methods are inherited\Nbut Dialogue: 0,0:16:27.29,0:16:32.11,Default,,0000,0000,0000,,not publicly accessible, right. Now private\Nmethods are inherited Dialogue: 0,0:16:32.11,0:16:36.65,Default,,0000,0000,0000,,but not publicly accessible, right? So what\Nare private Dialogue: 0,0:16:36.65,0:16:41.13,Default,,0000,0000,0000,,metho- protected methods? Contrary to popular\Nbelief, in Ruby Dialogue: 0,0:16:41.13,0:16:46.49,Default,,0000,0000,0000,,protected methods actually work with objects\Nand not classes. Dialogue: 0,0:16:46.49,0:16:49.61,Default,,0000,0000,0000,,And you can invoke a protected method on another Dialogue: 0,0:16:49.61,0:16:54.34,Default,,0000,0000,0000,,object within the same lineage. And I say,\Nwhat Dialogue: 0,0:16:54.34,0:17:01.34,Default,,0000,0000,0000,,the... what? Better explained with an example.\NSimple example, Dialogue: 0,0:17:01.61,0:17:03.06,Default,,0000,0000,0000,,for the sake of brevity I put the initializer Dialogue: 0,0:17:03.06,0:17:09.23,Default,,0000,0000,0000,,in one line. What is the output, people? Don't Dialogue: 0,0:17:09.23,0:17:15.04,Default,,0000,0000,0000,,be shy. You have bumblebee to help you out. Dialogue: 0,0:17:15.04,0:17:19.99,Default,,0000,0000,0000,,No takers. Come on man, that's like pretty\Nobvious Dialogue: 0,0:17:19.99,0:17:23.05,Default,,0000,0000,0000,,right. You can't call a protected method on\Nan Dialogue: 0,0:17:23.05,0:17:30.05,Default,,0000,0000,0000,,object, right? Simple stuff. However. Now\Nbeginners, so-called beginners Dialogue: 0,0:17:31.34,0:17:33.43,Default,,0000,0000,0000,,can tune out. This is fun. I added a Dialogue: 0,0:17:33.43,0:17:38.74,Default,,0000,0000,0000,,method called fights. Same piece of code.\NWhat is Dialogue: 0,0:17:38.74,0:17:44.07,Default,,0000,0000,0000,,the output? Take a wild guess, man. Go for Dialogue: 0,0:17:44.07,0:17:51.07,Default,,0000,0000,0000,,it. So either Megatron or Decepticon. Any\Nother deceptive Dialogue: 0,0:17:52.35,0:17:59.35,Default,,0000,0000,0000,,ideas? Guys, very practically, a quick lesson\Nin human Dialogue: 0,0:17:59.88,0:18:02.71,Default,,0000,0000,0000,,psychology. If that didn't work, would I have\Nthat Dialogue: 0,0:18:02.71,0:18:08.15,Default,,0000,0000,0000,,slide up there again? It works, man. It works. Dialogue: 0,0:18:08.15,0:18:09.94,Default,,0000,0000,0000,,But why did it work and how did it Dialogue: 0,0:18:09.94,0:18:13.43,Default,,0000,0000,0000,,work? The interesting part is that piece of\Nline, Dialogue: 0,0:18:13.43,0:18:15.66,Default,,0000,0000,0000,,earlier in the previous slide, prime dot nick\Ndid Dialogue: 0,0:18:15.66,0:18:18.55,Default,,0000,0000,0000,,not work, but here target dot nick actually\Nworks. Dialogue: 0,0:18:18.55,0:18:22.12,Default,,0000,0000,0000,,I have called a protected method on an object. Dialogue: 0,0:18:22.12,0:18:25.96,Default,,0000,0000,0000,,Now that same lineage means that because I'm\Ninside Dialogue: 0,0:18:25.96,0:18:28.95,Default,,0000,0000,0000,,the class Autobot, because I'm calling a method\Non Dialogue: 0,0:18:28.95,0:18:32.32,Default,,0000,0000,0000,,the prime object, which is in, which is in Dialogue: 0,0:18:32.32,0:18:36.19,Default,,0000,0000,0000,,Autobot class, and since another object called\NMegatron there Dialogue: 0,0:18:36.19,0:18:40.81,Default,,0000,0000,0000,,is of the same lineage, it's also an Autobot. Dialogue: 0,0:18:40.81,0:18:46.85,Default,,0000,0000,0000,,I can call the protected methods. So why didn't Dialogue: 0,0:18:46.85,0:18:49.90,Default,,0000,0000,0000,,it work earlier? Because everything in Ruby\Nis an Dialogue: 0,0:18:49.90,0:18:52.34,Default,,0000,0000,0000,,object. If you're trying to start prime dot\Nnick Dialogue: 0,0:18:52.34,0:18:55.14,Default,,0000,0000,0000,,and the previous case was outside the scope.\NSo Dialogue: 0,0:18:55.14,0:18:57.64,Default,,0000,0000,0000,,it was effectively in some main class, not\Nthe Dialogue: 0,0:18:57.64,0:19:00.73,Default,,0000,0000,0000,,same lineage, so it doesn't work. So Ruby\Nactually Dialogue: 0,0:19:00.73,0:19:04.40,Default,,0000,0000,0000,,works in the traditional way, but has different\Ninternal Dialogue: 0,0:19:04.40,0:19:07.38,Default,,0000,0000,0000,,meanings. And if now this was getting a little Dialogue: 0,0:19:07.38,0:19:10.43,Default,,0000,0000,0000,,complicated, how many of you all thought there\Nare Dialogue: 0,0:19:10.43,0:19:12.43,Default,,0000,0000,0000,,keywords in Ruby? Cause that man there is\Ngonna Dialogue: 0,0:19:12.43,0:19:14.26,Default,,0000,0000,0000,,come and shoot you if you think Ruby has Dialogue: 0,0:19:14.26,0:19:21.26,Default,,0000,0000,0000,,keywords. Does that code work? Is it even\Nvalid? Dialogue: 0,0:19:23.70,0:19:29.64,Default,,0000,0000,0000,,Should it give me a syntax error? If, how Dialogue: 0,0:19:29.64,0:19:30.99,Default,,0000,0000,0000,,many of you think it will give me an Dialogue: 0,0:19:30.99,0:19:33.46,Default,,0000,0000,0000,,error? Syntax error too? What's wrong with\Nyou? Have Dialogue: 0,0:19:33.46,0:19:37.07,Default,,0000,0000,0000,,you gone mad?-kind of errors. Any takers for\Nsyntax Dialogue: 0,0:19:37.07,0:19:40.01,Default,,0000,0000,0000,,errors? Probably not. But if not, then I want Dialogue: 0,0:19:40.01,0:19:41.28,Default,,0000,0000,0000,,to ask you know what is the output of Dialogue: 0,0:19:41.28,0:19:48.28,Default,,0000,0000,0000,,this code? Seriously. There it is, seriously.\NQuestion is, Dialogue: 0,0:19:50.44,0:19:51.71,Default,,0000,0000,0000,,how many of you all thought this is an Dialogue: 0,0:19:51.71,0:19:55.40,Default,,0000,0000,0000,,error called stack_too_deep. Cause when I\Ncall false it Dialogue: 0,0:19:55.40,0:19:57.77,Default,,0000,0000,0000,,calls true, once you call true it will call Dialogue: 0,0:19:57.77,0:20:02.25,Default,,0000,0000,0000,,false. And it goes into a recursive loop and Dialogue: 0,0:20:02.25,0:20:08.33,Default,,0000,0000,0000,,case stack_too_deep. Any takers for stack_too_deep?\NHigher, higher! And Dialogue: 0,0:20:08.33,0:20:12.24,Default,,0000,0000,0000,,how many think it will actually work? All\Nright. Dialogue: 0,0:20:12.24,0:20:15.51,Default,,0000,0000,0000,,The rest of the people, you all are beginners. Dialogue: 0,0:20:15.51,0:20:17.30,Default,,0000,0000,0000,,But yeah this works. So it does not stack_too_deep. Dialogue: 0,0:20:17.30,0:20:21.68,Default,,0000,0000,0000,,This actually works because true, true's resolution\Nis immediately Dialogue: 0,0:20:21.68,0:20:24.80,Default,,0000,0000,0000,,determined as the boolean value. However if\NI had Dialogue: 0,0:20:24.80,0:20:29.65,Default,,0000,0000,0000,,changed these two particular statements, the\Ncontent in the Dialogue: 0,0:20:29.65,0:20:32.13,Default,,0000,0000,0000,,methods to self dot false and self dot true Dialogue: 0,0:20:32.13,0:20:39.13,Default,,0000,0000,0000,,I would probably get stack_too_deep. Not probably,\Ndefinitely get Dialogue: 0,0:20:39.19,0:20:42.27,Default,,0000,0000,0000,,stack_too_deep. OK. So. If this wasn't complex\Nenough for Dialogue: 0,0:20:42.27,0:20:49.20,Default,,0000,0000,0000,,you, let's go to modules, the mysterious modules.\NYou Dialogue: 0,0:20:49.20,0:20:51.03,Default,,0000,0000,0000,,know what the bull I have with my good Dialogue: 0,0:20:51.03,0:20:54.66,Default,,0000,0000,0000,,friend module, which has power, Megatron is\Nsuper powerful, Dialogue: 0,0:20:54.66,0:20:57.99,Default,,0000,0000,0000,,and he's a force, he's evil. And I want Dialogue: 0,0:20:57.99,0:21:00.91,Default,,0000,0000,0000,,to put that in my class Hanuman. note the Dialogue: 0,0:21:00.91,0:21:04.07,Default,,0000,0000,0000,,star, because that's true. I want the power\Nof Dialogue: 0,0:21:04.07,0:21:10.59,Default,,0000,0000,0000,,Megatron with Hanuman. Hanuman! Unfortunately\Nthis will not go Dialogue: 0,0:21:10.59,0:21:13.46,Default,,0000,0000,0000,,down too well religiously for us, because\Nthough it Dialogue: 0,0:21:13.46,0:21:15.89,Default,,0000,0000,0000,,will be Hanuman will be as powerful as Megatron, Dialogue: 0,0:21:15.89,0:21:19.96,Default,,0000,0000,0000,,Hanuman is now evil! So what do I do? Dialogue: 0,0:21:19.96,0:21:22.56,Default,,0000,0000,0000,,Is there a way I can cherry-pick from Megatron, Dialogue: 0,0:21:22.56,0:21:25.65,Default,,0000,0000,0000,,saying, I want the power of Megatron but I Dialogue: 0,0:21:25.65,0:21:32.65,Default,,0000,0000,0000,,don't want to be evil? What do I do? Dialogue: 0,0:21:33.06,0:21:35.70,Default,,0000,0000,0000,,I require. Note, I have not included Megatron,\NI Dialogue: 0,0:21:35.70,0:21:39.98,Default,,0000,0000,0000,,require the Megatron method- Megatron file,\NMegatron RB. I Dialogue: 0,0:21:39.98,0:21:43.27,Default,,0000,0000,0000,,define a method called power and I go to Dialogue: 0,0:21:43.27,0:21:46.19,Default,,0000,0000,0000,,the module, tell him to give me that instance Dialogue: 0,0:21:46.19,0:21:49.60,Default,,0000,0000,0000,,method called power, which gives me something\Ncalled an Dialogue: 0,0:21:49.60,0:21:54.03,Default,,0000,0000,0000,,unbounded method. And then I bind it to me, Dialogue: 0,0:21:54.03,0:21:59.73,Default,,0000,0000,0000,,that is self, and I call it. And that Dialogue: 0,0:21:59.73,0:22:06.73,Default,,0000,0000,0000,,makes my Hanuman religiously acceptable to\Nsociety. Question? No. Dialogue: 0,0:22:09.15,0:22:11.87,Default,,0000,0000,0000,,So note self, self is the object call. So Dialogue: 0,0:22:11.87,0:22:13.68,Default,,0000,0000,0000,,it's not working on the class call, it's actually Dialogue: 0,0:22:13.68,0:22:16.26,Default,,0000,0000,0000,,working on the instance. So every object,\Nevery instance Dialogue: 0,0:22:16.26,0:22:21.66,Default,,0000,0000,0000,,of Hanuman, will actually get the power of\NMegatron. Dialogue: 0,0:22:21.66,0:22:26.89,Default,,0000,0000,0000,,And with that I end my talk and thank Dialogue: 0,0:22:26.89,0:22:29.98,Default,,0000,0000,0000,,my two assistants here. I have, I'm open for Dialogue: 0,0:22:29.98,0:22:33.82,Default,,0000,0000,0000,,a few questions. Do I have the time, guys? Dialogue: 0,0:22:33.82,0:22:35.91,Default,,0000,0000,0000,,Satish, do I have some time? For questions?\NYay! Dialogue: 0,0:22:35.91,0:22:40.65,Default,,0000,0000,0000,,We have a lot of time for questions! All Dialogue: 0,0:22:40.65,0:22:47.65,Default,,0000,0000,0000,,right, you. Thank you. You have a question\Nthere. Dialogue: 0,0:22:49.19,0:22:52.97,Default,,0000,0000,0000,,QUESTION: What exactly lead you to title this\Ntalk Dialogue: 0,0:22:52.97,0:22:56.84,Default,,0000,0000,0000,,as the Dark Side of Ruby? G.R.: Oooh. Now Dialogue: 0,0:22:56.84,0:22:59.66,Default,,0000,0000,0000,,he killed me, didn't he? So that was a, Dialogue: 0,0:22:59.66,0:23:01.51,Default,,0000,0000,0000,,there's a two-sided answer to that. One was\Nto Dialogue: 0,0:23:01.51,0:23:06.02,Default,,0000,0000,0000,,fool the organizers, to get the CF?? (00:23:05:23)\Naccepted. Dialogue: 0,0:23:06.02,0:23:10.51,Default,,0000,0000,0000,,But more importantly, the dark side of Ruby\Ntries Dialogue: 0,0:23:10.51,0:23:12.13,Default,,0000,0000,0000,,to bring out the weirdness in Ruby, which\Nis Dialogue: 0,0:23:12.13,0:23:15.70,Default,,0000,0000,0000,,not the evil part, but the hidden part. Like Dialogue: 0,0:23:15.70,0:23:18.13,Default,,0000,0000,0000,,the dark side of the moon where we have Dialogue: 0,0:23:18.13,0:23:20.18,Default,,0000,0000,0000,,all these kind of stuff that breaks, the gotchas, Dialogue: 0,0:23:20.18,0:23:22.87,Default,,0000,0000,0000,,the moment that we feel that are going to Dialogue: 0,0:23:22.87,0:23:25.74,Default,,0000,0000,0000,,help but you don't really need to care about Dialogue: 0,0:23:25.74,0:23:28.16,Default,,0000,0000,0000,,it, but it's really, really important that\Nyou know Dialogue: 0,0:23:28.16,0:23:32.84,Default,,0000,0000,0000,,these things exist. That's why Dark Side of\NRuby. Dialogue: 0,0:23:32.84,0:23:37.92,Default,,0000,0000,0000,,So I still love Ruby - no offense. Any Dialogue: 0,0:23:37.92,0:23:44.92,Default,,0000,0000,0000,,other questions? Yes sir. QUESTION: So have\Nyou suffered Dialogue: 0,0:23:45.12,0:23:47.04,Default,,0000,0000,0000,,because of any of these gotchas in you work? Dialogue: 0,0:23:47.04,0:23:50.94,Default,,0000,0000,0000,,G.R.: Absolutely! This is all part of experience.\NPart Dialogue: 0,0:23:50.94,0:23:55.86,Default,,0000,0000,0000,,(00:23:53:00 ??) is part of experience, part\Nis training, Dialogue: 0,0:23:55.86,0:23:59.31,Default,,0000,0000,0000,,and partly is preparation for my talk, trying\Nto Dialogue: 0,0:23:59.31,0:24:02.03,Default,,0000,0000,0000,,find out these terms, and figuring things\Nout. There's Dialogue: 0,0:24:02.03,0:24:04.17,Default,,0000,0000,0000,,a lot of stuff that I've actually kept out, Dialogue: 0,0:24:04.17,0:24:08.37,Default,,0000,0000,0000,,like you know ?? (00:24:07:03) games. Lots\Nof fun Dialogue: 0,0:24:08.37,0:24:10.85,Default,,0000,0000,0000,,with method missing. I haven't even touched\Nupon blocks Dialogue: 0,0:24:10.85,0:24:12.97,Default,,0000,0000,0000,,and ?? There's lots of funny stuff which happens Dialogue: 0,0:24:12.97,0:24:17.13,Default,,0000,0000,0000,,there. But I have only half an hour. So Dialogue: 0,0:24:17.13,0:24:18.45,Default,,0000,0000,0000,,the question to you guys also is that in Dialogue: 0,0:24:18.45,0:24:20.26,Default,,0000,0000,0000,,case you find some of these funny things which Dialogue: 0,0:24:20.26,0:24:23.04,Default,,0000,0000,0000,,happen in Ruby, and are able to explain it Dialogue: 0,0:24:23.04,0:24:24.77,Default,,0000,0000,0000,,or not able to explain it, send me a Dialogue: 0,0:24:24.77,0:24:27.58,Default,,0000,0000,0000,,Tweet, send me an email, and I will probably Dialogue: 0,0:24:27.58,0:24:30.60,Default,,0000,0000,0000,,investigate and improve my talk at your expense.\NQUESTION: Dialogue: 0,0:24:30.60,0:24:35.38,Default,,0000,0000,0000,,Yeah. So the other question is, are there\Nsome Dialogue: 0,0:24:35.38,0:24:39.85,Default,,0000,0000,0000,,practices, certain things that I follow, so\Nthat I Dialogue: 0,0:24:39.85,0:24:42.73,Default,,0000,0000,0000,,don't get, I don't encounter these? G.R.:\NWell, so Dialogue: 0,0:24:42.73,0:24:44.22,Default,,0000,0000,0000,,one thing, these aren't problems. What I wanted\Nto Dialogue: 0,0:24:44.22,0:24:45.90,Default,,0000,0000,0000,,point out here is that this is not a Dialogue: 0,0:24:45.90,0:24:47.39,Default,,0000,0000,0000,,bad part of Ruby, but these are the things Dialogue: 0,0:24:47.39,0:24:50.13,Default,,0000,0000,0000,,that we take for granted. So knowing about\Nprotected Dialogue: 0,0:24:50.13,0:24:55.05,Default,,0000,0000,0000,,and private being different is important.\NBut not mandatory Dialogue: 0,0:24:55.05,0:24:57.91,Default,,0000,0000,0000,,for us to work as Rails programmers. But if Dialogue: 0,0:24:57.91,0:25:01.75,Default,,0000,0000,0000,,you know that, how protected and private actually\Nwork, Dialogue: 0,0:25:01.75,0:25:05.05,Default,,0000,0000,0000,,it makes us better programmers. So best practices\Nof Dialogue: 0,0:25:05.05,0:25:07.45,Default,,0000,0000,0000,,Ruby are already there. You know there are\Nthings Dialogue: 0,0:25:07.45,0:25:11.38,Default,,0000,0000,0000,,like flip-flops in Ruby which is for lack\Nof Dialogue: 0,0:25:11.38,0:25:15.22,Default,,0000,0000,0000,,a better term, a mind star star star star. Dialogue: 0,0:25:15.22,0:25:18.01,Default,,0000,0000,0000,,But, I do not recommend it. But it's there. Dialogue: 0,0:25:18.01,0:25:20.86,Default,,0000,0000,0000,,There are plenty of other things in Ruby,\Ntoo. Dialogue: 0,0:25:20.86,0:25:24.62,Default,,0000,0000,0000,,Which work, which should work, which you should\Nuse. Dialogue: 0,0:25:24.62,0:25:26.97,Default,,0000,0000,0000,,The bottom line is that Ruby gives us the Dialogue: 0,0:25:26.97,0:25:29.53,Default,,0000,0000,0000,,maximum flexibility to build the way we want\Nto Dialogue: 0,0:25:29.53,0:25:33.05,Default,,0000,0000,0000,,build our code. So with great power comes\Ngreat Dialogue: 0,0:25:33.05,0:25:35.53,Default,,0000,0000,0000,,responsibility. And sometimes it's irresponsible.\NSo it worked out Dialogue: 0,0:25:35.53,0:25:39.04,Default,,0000,0000,0000,,great. Yeah. QUESTION: So is there a good\Nparts Dialogue: 0,0:25:39.04,0:25:41.46,Default,,0000,0000,0000,,of Ruby, like good parts of Java- G.R.: What? Dialogue: 0,0:25:41.46,0:25:43.89,Default,,0000,0000,0000,,QUESTION: Good parts of Ruby? G.R.: Oh, good\Nparts? Dialogue: 0,0:25:43.89,0:25:45.65,Default,,0000,0000,0000,,Everything! I've been working in Ruby for\Nsix years Dialogue: 0,0:25:45.65,0:25:48.05,Default,,0000,0000,0000,,and I still love it. QUESTION: No, there is Dialogue: 0,0:25:48.05,0:25:49.32,Default,,0000,0000,0000,,a famous book called Good Parts of JavaScript,\Na Dialogue: 0,0:25:49.32,0:25:51.60,Default,,0000,0000,0000,,very thin book that allows a subset of language Dialogue: 0,0:25:51.60,0:25:55.60,Default,,0000,0000,0000,,that is very safe to use, that you can Dialogue: 0,0:25:55.60,0:26:02.11,Default,,0000,0000,0000,,be very productive in. So do you, have you Dialogue: 0,0:26:02.11,0:26:02.20,Default,,0000,0000,0000,,come across something that says, like, there's\Na subset Dialogue: 0,0:26:02.20,0:26:02.30,Default,,0000,0000,0000,,that you should stick to and use? G.R.: So Dialogue: 0,0:26:02.30,0:26:05.39,Default,,0000,0000,0000,,the best part about Ruby that I like is Dialogue: 0,0:26:05.39,0:26:09.07,Default,,0000,0000,0000,,the closures, which is completely misunderstood,\Nbecause every time Dialogue: 0,0:26:09.07,0:26:11.39,Default,,0000,0000,0000,,I talk to any person who's getting into Ruby Dialogue: 0,0:26:11.39,0:26:12.62,Default,,0000,0000,0000,,and I show them what a closure is they're Dialogue: 0,0:26:12.62,0:26:15.06,Default,,0000,0000,0000,,like yeah, that's a loop. But it's not. It's Dialogue: 0,0:26:15.06,0:26:17.67,Default,,0000,0000,0000,,like far more better than that. And it's far Dialogue: 0,0:26:17.67,0:26:20.66,Default,,0000,0000,0000,,more - it's more intuitive. It gets into the Dialogue: 0,0:26:20.66,0:26:23.41,Default,,0000,0000,0000,,details and gives us so much more incentive\Nabout Dialogue: 0,0:26:23.41,0:26:26.16,Default,,0000,0000,0000,,learning how Ruby internals work, that we\Ntend to Dialogue: 0,0:26:26.16,0:26:29.10,Default,,0000,0000,0000,,actually ignore it in Rails. And I only (00:26:30:29) Dialogue: 0,0:26:29.10,0:26:31.53,Default,,0000,0000,0000,,have a lot of respect for people who have Dialogue: 0,0:26:31.53,0:26:33.01,Default,,0000,0000,0000,,learned Ruby and gone to Rails, because they\Nknow Dialogue: 0,0:26:33.01,0:26:35.79,Default,,0000,0000,0000,,the right thing, other than most of us, including Dialogue: 0,0:26:35.79,0:26:38.34,Default,,0000,0000,0000,,me, who got into Rails and then fell in Dialogue: 0,0:26:38.34,0:26:41.77,Default,,0000,0000,0000,,love with Ruby. So it's different. QUESTION:\NSo is Dialogue: 0,0:26:41.77,0:26:46.31,Default,,0000,0000,0000,,Ruby the good parts the next book? G.R.: Could Dialogue: 0,0:26:46.31,0:26:48.09,Default,,0000,0000,0000,,be. But I'll need a lot of community support Dialogue: 0,0:26:48.09,0:26:54.90,Default,,0000,0000,0000,,for that. Yes? QUESTION: Yeah, hi, thanks\Nfor the Dialogue: 0,0:26:54.90,0:26:57.39,Default,,0000,0000,0000,,talk. Just (00:26:55:09). I have been checking\Nout Exorcism Dialogue: 0,0:26:57.39,0:26:59.03,Default,,0000,0000,0000,,dot IO. I don't know if you guys have Dialogue: 0,0:26:59.03,0:27:01.75,Default,,0000,0000,0000,,heard of it. So it's actually started by Katrina, Dialogue: 0,0:27:01.75,0:27:04.00,Default,,0000,0000,0000,,who's part of the Ruby Rogues, and I have Dialogue: 0,0:27:04.00,0:27:06.53,Default,,0000,0000,0000,,had a wonderful time running stuff from Ruby,\Nlike Dialogue: 0,0:27:06.53,0:27:08.94,Default,,0000,0000,0000,,I have been working Ruby for ?? (00:27:08:20)\Nfor Dialogue: 0,0:27:08.94,0:27:11.65,Default,,0000,0000,0000,,years and also gotchas- G.R.: So, Exorcism\Ndot IO. Dialogue: 0,0:27:11.65,0:27:14.56,Default,,0000,0000,0000,,That's great. QUESTION: Like really good Ruby\Nidioms that Dialogue: 0,0:27:14.56,0:27:15.50,Default,,0000,0000,0000,,like so it's basically what happens is you,\Nthere Dialogue: 0,0:27:15.50,0:27:17.21,Default,,0000,0000,0000,,are around ten languages if I'm not wrong.\NYou Dialogue: 0,0:27:17.21,0:27:21.16,Default,,0000,0000,0000,,can pick Ruby, you can sub in your solutions. Dialogue: 0,0:27:21.16,0:27:23.66,Default,,0000,0000,0000,,People can look at your code. They can give Dialogue: 0,0:27:23.66,0:27:26.81,Default,,0000,0000,0000,,good reviews. You can help out others with\Nyour Dialogue: 0,0:27:26.81,0:27:30.19,Default,,0000,0000,0000,,suggestions. Yeah- G.R.: But to add to that,\Nthere Dialogue: 0,0:27:30.19,0:27:32.37,Default,,0000,0000,0000,,is also some interesting - I'm not sure if Dialogue: 0,0:27:32.37,0:27:35.87,Default,,0000,0000,0000,,you all have heard of Winbgall (00:27:33:08).\NWingolf was Dialogue: 0,0:27:35.87,0:27:38.67,Default,,0000,0000,0000,,a gem and a simple tool where you can Dialogue: 0,0:27:38.67,0:27:42.15,Default,,0000,0000,0000,,report a problem statement, and using whim,\Nyou know Dialogue: 0,0:27:42.15,0:27:46.15,Default,,0000,0000,0000,,execute that in the least number of key presses. Dialogue: 0,0:27:46.15,0:27:48.65,Default,,0000,0000,0000,,Similarly there are a few initiatives for\NRuby golf, Dialogue: 0,0:27:48.65,0:27:51.35,Default,,0000,0000,0000,,where you can actually try things like, the\Nbeginner Dialogue: 0,0:27:51.35,0:27:54.21,Default,,0000,0000,0000,,?? they actually said they have things with\N?? Dialogue: 0,0:27:54.21,0:27:57.79,Default,,0000,0000,0000,,you know stuff like, write this piece of code Dialogue: 0,0:27:57.79,0:28:01.13,Default,,0000,0000,0000,,without using arrays, or without using the\Nequality operator. Dialogue: 0,0:28:01.13,0:28:03.50,Default,,0000,0000,0000,,And then you start, your mind starts churning,\Nand Dialogue: 0,0:28:03.50,0:28:05.09,Default,,0000,0000,0000,,then you dig deeper into Ruby and find other Dialogue: 0,0:28:05.09,0:28:07.14,Default,,0000,0000,0000,,things. So the best way to find these things Dialogue: 0,0:28:07.14,0:28:10.85,Default,,0000,0000,0000,,is to try Ruby ?? All right we had Dialogue: 0,0:28:10.85,0:28:13.38,Default,,0000,0000,0000,,a question there too. QUESTION: Not really\Na question, Dialogue: 0,0:28:13.38,0:28:16.21,Default,,0000,0000,0000,,but just a suggestion, actually, to folks\Nwho are Dialogue: 0,0:28:16.21,0:28:18.74,Default,,0000,0000,0000,,trying to learn Ruby. I like that he pointed Dialogue: 0,0:28:18.74,0:28:20.70,Default,,0000,0000,0000,,out that some of the things that we've learned Dialogue: 0,0:28:20.70,0:28:24.29,Default,,0000,0000,0000,,in college, classical logic and stuff doesn't\Nreally apply. Dialogue: 0,0:28:24.29,0:28:27.75,Default,,0000,0000,0000,,What really helped me understand differences\Nwas that treat Dialogue: 0,0:28:27.75,0:28:30.84,Default,,0000,0000,0000,,Ruby as a object-focused language and most\Nof the Dialogue: 0,0:28:30.84,0:28:33.12,Default,,0000,0000,0000,,languages that you probably end up working\Nwith, Java, Dialogue: 0,0:28:33.12,0:28:36.28,Default,,0000,0000,0000,,C sharp, they'll be class focused. So concepts\Nlike Dialogue: 0,0:28:36.28,0:28:39.34,Default,,0000,0000,0000,,private, protected, just like you mentioned,\Nare all object-level Dialogue: 0,0:28:39.34,0:28:41.58,Default,,0000,0000,0000,,concepts in Ruby. In fact if you wanted to Dialogue: 0,0:28:41.58,0:28:44.57,Default,,0000,0000,0000,,draw parallels again JavaScript is a good\Nparallel because Dialogue: 0,0:28:44.57,0:28:47.23,Default,,0000,0000,0000,,JavaScript is also an object-focused language.\NSo there are a Dialogue: 0,0:28:47.23,0:28:48.95,Default,,0000,0000,0000,,lot of parallels between JavaScript and Ruby, and Dialogue: 0,0:28:49.00,0:28:51.70,Default,,0000,0000,0000,,less between Java and Ruby. Dialogue: 0,0:28:51.70,0:28:52.70,Default,,0000,0000,0000,,QUERANT: Yeah, and- Dialogue: 0,0:28:52.74,0:28:55.70,Default,,0000,0000,0000,,It's like the dot, I'm sorry, that dot thing just amazed me. Dialogue: 0,0:28:55.70,0:28:58.78,Default,,0000,0000,0000,,??, just having a dot. Dialogue: 0,0:28:58.90,0:29:01.46,Default,,0000,0000,0000,,and I was actually kind of disappointed when it Dialogue: 0,0:29:01.46,0:29:04.04,Default,,0000,0000,0000,,ended. I just wanted more. OK. Dialogue: 0,0:29:04.14,0:29:05.14,Default,,0000,0000,0000,,G.R.: Cool. Thank you. Dialogue: 0,0:29:08.26,0:29:09.26,Default,,0000,0000,0000,,Yes? Dialogue: 0,0:29:11.08,0:29:13.20,Default,,0000,0000,0000,,The Well-Grounded Rubyist. A must read. Dialogue: 0,0:29:14.26,0:29:15.68,Default,,0000,0000,0000,,V.O.: Somebody Tweet about it, please. Dialogue: 0,0:29:16.34,0:29:17.68,Default,,0000,0000,0000,,V.O.: We'll take one last question. Dialogue: 0,0:29:19.50,0:29:21.84,Default,,0000,0000,0000,,QUERANT: How does it help to have protected and private method Dialogue: 0,0:29:21.94,0:29:24.94,Default,,0000,0000,0000,,different from other languages? The way Ruby does it? Dialogue: 0,0:29:25.16,0:29:27.78,Default,,0000,0000,0000,,G.R.: I'm sorry. Did you ask what is different between protected and private- Dialogue: 0,0:29:27.78,0:29:30.14,Default,,0000,0000,0000,,QUERANT: No. How does it help to have a different design implementation, Dialogue: 0,0:29:30.14,0:29:31.14,Default,,0000,0000,0000,,to have it different. Dialogue: 0,0:29:31.14,0:29:33.72,Default,,0000,0000,0000,,G.R.: Oh. Excellent. And I love answering this question. Dialogue: 0,0:29:33.72,0:29:35.56,Default,,0000,0000,0000,,Though sometimes it can be a little long. Dialogue: 0,0:29:35.56,0:29:39.76,Default,,0000,0000,0000,,Why is private and protected different private and protected different in Ruby than Dialogue: 0,0:29:39.76,0:29:41.54,Default,,0000,0000,0000,,in other traditional standard languages? Dialogue: 0,0:29:41.54,0:29:43.16,Default,,0000,0000,0000,,Because Ruby did it right. Dialogue: 0,0:29:43.16,0:29:44.84,Default,,0000,0000,0000,,That's how it's supposed to be. Dialogue: 0,0:29:44.84,0:29:46.24,Default,,0000,0000,0000,,Example. Dialogue: 0,0:29:48.18,0:29:50.44,Default,,0000,0000,0000,,You know, when we talk about object-oriented programming, Dialogue: 0,0:29:50.44,0:29:52.68,Default,,0000,0000,0000,,it's supposed to be about objects. Things that you can see and touch. Dialogue: 0,0:29:52.68,0:29:55.06,Default,,0000,0000,0000,,For example: Inheritance. Dialogue: 0,0:29:55.06,0:29:57.02,Default,,0000,0000,0000,,Right. What is inheritance? Dialogue: 0,0:29:57.02,0:29:59.38,Default,,0000,0000,0000,,In, put it in, no uncertain term, though, it's my Dialogue: 0,0:29:59.38,0:30:01.08,Default,,0000,0000,0000,,?? Dialogue: 0,0:30:01.82,0:30:04.90,Default,,0000,0000,0000,,Right. My inherited land my from my ancestors. Dialogue: 0,0:30:06.50,0:30:08.74,Default,,0000,0000,0000,,It's private. It's inherited. Dialogue: 0,0:30:08.74,0:30:11.62,Default,,0000,0000,0000,,You can. It, it comes within the family. Dialogue: 0,0:30:11.62,0:30:13.64,Default,,0000,0000,0000,,It can be protected. Can be private. Dialogue: 0,0:30:13.64,0:30:16.90,Default,,0000,0000,0000,,But, if you have your dad's wallet, do you inherit it? Dialogue: 0,0:30:18.28,0:30:20.44,Default,,0000,0000,0000,,You can choose to use it. You can choose not to use it. Dialogue: 0,0:30:20.50,0:30:21.62,Default,,0000,0000,0000,,It's just there. Dialogue: 0,0:30:21.62,0:30:24.98,Default,,0000,0000,0000,,The inheritance of land can be protected because it always stays in the family. Dialogue: 0,0:30:24.98,0:30:28.44,Default,,0000,0000,0000,,Like, for example, the money in the family is protected. Dialogue: 0,0:30:28.44,0:30:31.34,Default,,0000,0000,0000,,But that's always dealing with parents and children. Dialogue: 0,0:30:31.34,0:30:35.46,Default,,0000,0000,0000,,You can't go, your father. Just because you have a father and I have a father Dialogue: 0,0:30:35.46,0:30:37.00,Default,,0000,0000,0000,,I can't go asking your father for money. Dialogue: 0,0:30:37.00,0:30:40.70,Default,,0000,0000,0000,,Right. It's immense, how you determine. And of course public is the same everywhere. Dialogue: 0,0:30:41.26,0:30:43.96,Default,,0000,0000,0000,,So Ruby did it right, because it's, everything's object-centric. Dialogue: 0,0:30:44.68,0:30:47.94,Default,,0000,0000,0000,,Exactly what Aman said just now. Everything's object centric. Dialogue: 0,0:30:48.66,0:30:52.14,Default,,0000,0000,0000,,And, traditionally in object-oriented concepts, it started off right Dialogue: 0,0:30:52.14,0:30:57.02,Default,,0000,0000,0000,,and then it went all across the tangent, where you had this inheritance, and Dialogue: 0,0:30:57.02,0:30:59.12,Default,,0000,0000,0000,,classes and stuff like that. All the standard Dialogue: 0,0:31:00.06,0:31:06.48,Default,,0000,0000,0000,,things that I never talk about: incapsulation, abstraction, polymorphism Dialogue: 0,0:31:06.48,0:31:09.44,Default,,0000,0000,0000,,which seem to be the essence of object-oriented programming but is not. Dialogue: 0,0:31:10.24,0:31:11.84,Default,,0000,0000,0000,,V.O.: So, a follow-up question. Dialogue: 0,0:31:11.84,0:31:16.38,Default,,0000,0000,0000,,I have it. So is there a well-known pattern that makes use of, makes good of Dialogue: 0,0:31:16.38,0:31:18.20,Default,,0000,0000,0000,,private and protected? Dialogue: 0,0:31:18.98,0:31:19.98,Default,,0000,0000,0000,,We understand why- G.R.: Good qu- Dialogue: 0,0:31:19.98,0:31:20.98,Default,,0000,0000,0000,,QUERANT: Is it because it Dialogue: 0,0:31:20.98,0:31:24.40,Default,,0000,0000,0000,,G.R.: Include. Include. Include is an excellent example. Dialogue: 0,0:31:24.40,0:31:26.66,Default,,0000,0000,0000,,There are actually other patterns, too. Dialogue: 0,0:31:26.66,0:31:30.78,Default,,0000,0000,0000,,There are other patterns which allow for protected, protected is used very heavily for Dialogue: 0,0:31:30.78,0:31:34.08,Default,,0000,0000,0000,,all sorts of, the usually standard, why use protected, for example Dialogue: 0,0:31:34.08,0:31:37.18,Default,,0000,0000,0000,,protecting your password generation algorithm. Dialogue: 0,0:31:37.18,0:31:39.06,Default,,0000,0000,0000,,Something like that. But that's the deal with objects. Dialogue: 0,0:31:39.18,0:31:41.98,Default,,0000,0000,0000,,And since objects can be called only from their own lineage Dialogue: 0,0:31:41.98,0:31:43.94,Default,,0000,0000,0000,,you're always safe. Good question. Dialogue: 0,0:31:46.00,0:31:47.46,Default,,0000,0000,0000,,All right. V.O.: Anymore questions? Dialogue: 0,0:31:48.38,0:31:50.34,Default,,0000,0000,0000,,If there's anymore questions, we'll take it offline. Dialogue: 0,0:31:50.34,0:31:52.14,Default,,0000,0000,0000,,G.R.: Sure. Thank you so much Dialogue: 0,0:31:53.84,0:31:54.84,Default,,0000,0000,0000,,V.O.: Thanks Gautam.