 So David Black is here to deliver our final keynote and I'm really happy to have him. So enjoy all right. Thank you Thank you very much. I'm really glad to be here and I just I guess there's a kind of official closed-down thing You know tear down thing after my talk, but I just want to thank Jeremy and all of his co-organizers for all the work they've done for this event, which has been really really good I'm sure Jeremy you'll mention names maybe later if I don't remember them, but but anyway the point is we've had a great time And the food has been excellent copious and excellent I'm David Black. I am the director of ruby power and light A company that I started in 2006 it's basically a ruby and rails consultancy and I do a lot of training and Consulting and writing and so on and I mainly founded the company and Left my previous career in academics Because the name ruby power and light is so cool and so I felt that it just it was too good to miss I'm also one of the directors of ruby central which is the nonprofit Organization that brings you ruby conf and that co-produces rails conf and rails conf Europe with O'Reilly and we also we also do other things we have regional conference grants and and so forth And we've been around we were at ruby central was formed actually in the aftermath of the the first ruby conf in 2001 and I thought I would talk to you today about ruby I mean this is a little bit of a romp through some things about rubies old and new The Dickensian reference is really that I'm looking at ghosts of ruby past present and future They're friendly ghosts. This is not supposed to be a kind of you know, solemn or eerie experience And it's not very Dickensian. I mean I you know if I were better at finding illustrations I'd have sort of you know, what was it George Crook shank or whatever, you know illustrations from David Copperfield and stuff. I don't it's very you know kind of Bear bones in those terms, but I thought about this kind of past present and future ruby because there's so much talk nowadays about Future ruby and present ruby And sort of where that's going and as you know, there's a lot of different Implementations of ruby. There's also a lot of different versions of ruby and I'm actually going to be talking today mostly about different versions of ruby and Just to give you a very rough timeline. I know that nobody in this room is you know of of the conviction that Ruby was extracted from rails or something like that I mean, you know, we're all hip to the fact that ruby has been around for a while and again very rough But just you know back to 1994. I think it was February February something is what Matt's called ruby's birthday One point. Oh, it gets a little kind of hard to to pin down 1.0 seems to have been released, you know various versions of it during those two years and so forth just a few kind of how it's I actually managed to To get ruby 1.0 to compile recently I just thought it would be fun to you can actually get the FTP You know the the tar ball from the ruby FTP site and it doesn't if you're using a recent GCC It does not compile until you sort of stalk and slash it a little bit and you know Comment out some of the the things that don't compile these that's how you do it, right? That's yeah, so you comment out and delete stuff and eventually get it does compile If anybody wants my my hacked version of it, I'd be happy to share it with you now It was really interesting to me because I I started using ruby in late 2000 I am a pickaxe baby, which is to say I discovered the pickaxe book really about I think within about a week of its appearance I eat beginning of November of 2000 and You know, I've been doing a lot of pearl and stuff and I saw this book programming ruby on the shelf at borders The late lamented borders near my house. Um, I took the book off the shelf and opened it and You know basically kind of walked like this to the cash register. I just I couldn't you know, I couldn't take my eyes off I just thought this is so great. So that was late 2000. So Just in the timeline. I'm around You know 1.6.2 or something like that Now ruby 1.0 Therefore, you know kind of predates me certainly but I did want to see what it was like and I found some interest I think very interesting things certain things you you couldn't do. I mean, obviously, it's you know It's an early release but certain things that where I thought I was kind of on fairly safe territory, you know, ruby Dashie put s. Hello world Undefined method put s. Whoops. Okay. So you can't do put s You can't do you can do each you can't do map. Actually, it's a little misleading because there was collect So, oh, no, actually, it's not misleading because I I also put collect there I then I thought okay. Well, I'll get systematic about this. What methods does an array have so I said a dot methods And that was an unknown method. So it's a little bit out of luck And true was not true as we know it true was Capitalized and I don't know the history of that but I I somehow surmised that I'm not sure how I figure that one out But the cool thing is that as of Ruby 1.0 despite the lack of put s and and methods and so on Ruby was already Ruby and this is what I love about it that you you know You couldn't do put s but you could do this you could get into the singleton class of an object and Teach the object to be Different from the class that it was born from and that of course is the heart of Ruby if anything is So you could do that and here, you know I teach my object to to print high when I tell it X and so I say X and so on and it says hi Just another example, I mean it's kind of the same idea, but just here Over there. I have a module and I have an extend ease Attribute and off I go essentially extending another module with or actually says are extending an object with this This module in there again, you see down in the bottom left This is really all one little program just in two columns when the bottom left you see self extend object again You have that that hook That you can use and it's almost like the the meta programming stuff is Historically more fundamental to Ruby than than some of the programming stuff so to speak now I Decided to go a little further in Ruby 1.0 and look at the deck of cards now I use deck of cards examples in training and so forth a fair amount because actually decks of cards are you know They they're kind of good to just flush out some interesting things involving dealing with collections and so on So here, you know just again a couple of things, you know, I have here Include comparable so we had comparable already and as you know if you include comparable and if you define the spaceship operator then You get greater than and less than and greater than a less or greater than or equal to and so forth and and between and so on for free and The way I compare two cards with each other it is basically to say Where it I have a suits array and a ranks array and where in the ranks array does this card occur and where in the ranks? Array does the other card occur? But you know just a couple again, it's you know, it's not dramatically different from what we'd write today There's no percent W shorthand for the array of strings. There's no attra accessor. There's this attra suit true Which it's interesting that that was there then I've always disliked strongly the there's a handful of these Boolean second arguments in Ruby like Instance methods or just arguments something instance methods false, you know string dot instance methods false What it actually means is show me all the instance methods defined in this class or module But not the ones that it gets from its ancestors just the ones that are actually defined in it Why that's a state of falsehood? I don't know and it's a I mean, you know, this True actually means create a writer attribute along with a reader attribute I'm not a fan of those. I think so much cryptic Boolean arguments. But anyway, there it is and against the capitalized true and Here for the death side that was the I've got a playing cards module card class and then a deck class and Again, just a few things like in cards I basically my basic strategy is to have an array in an instance variable called cards and most of the you know Dealing and shuffling and so on really is is punted from the deck object to its cards object and I Don't think there is any percent block thing. I mean to implement each for my deck I believe I had to do this kind kind of the long way. I couldn't find a shorter way Today you could do it by capturing the block and then then kind of gluing the percent block to the to the new each I mean, there's also of course a million other ways to delegate methods But that wasn't there is no shuffle, but that's a little bit of a you know a little misleading because there's no shuffle until 1.9 anyway in the array class, but I wrote my little Shuffle thing that the way I shuffle is to sort the cards randomly. I I the usual idiom would be just rand spaceship rand I was getting Wrong number of method arguments zero for one with that apparently you had to do rand Something I and I just chose three. It's probably That's probably wrong. Isn't it? No, that's I Can't I don't know anyway It made the the algorithm may be wrong, but the idea is basically that You had to give it an argument and you couldn't just say ran And I have a nice deal method and it's sort of stupid peak method Which shows you the next card without actually dealing it and so forth So this is just you know It's show just a couple of things. I shuffle the deck. I peek at the deck. I deal five cards. I look at the hand It's a little hard to kind of parse here But basically the first line is just the card I peeked at the next five lines are actually an array of all the playing card objects and Then I just check the deck size at the end and sure enough it's down to 47 Again, just kind of interesting little discoveries. I think just kind of playing around with with 1.0 And again what most interesting to me was that there's kind of a scattering of things you can't do that you might Think of as kind of the bread and butter of ruby, you know like put ass and methods and stuff But other things that you can do like opening up singles in classes that to me It's very interesting to see that that was just you know there from the very beginning That really is kind of the the Foundation, you know that that kind of technique and architecture really the foundational ones so moving from the past to the present and The in ruby versions the present and future are a little bit Hard to tease apart And we'll look at that a bit. I thought it would be interesting to look at some of the Versions that are that are now available some of the kind of recent Developments in in some of the versions and I don't know how many of you kind of follow the the ongoing Release cycles and so forth and some of the discussions on ruby core and ruby talk but we're actually at an interesting point in I Think in the history of ruby versions and ruby versioning We have one point eight point six how many of you run one point eight point six as you're you know just sort of your ruby thing and How many of the ones that didn't raise your hands how many of you are running not the mats ruby interpreter But Jay ruby or something Yeah, okay, how many of you use one eight seven What's it like? Well, yeah, I mean I one eight seven I'm actually kind of interested in in what people find with one eight seven one eight seven I mean one eight six has been around for a while and You know is reasonably stable. Although there were a month or so ago There were some security patches and so on but I mean that's you know, that's kind of neither here nor there in the long run But one eight seven is basically a backport of a lot of one point nine features To one eight six, I mean it's one point eight six plus a lot of one point nine stuff I yeah, it's a little bit maybe unfair to say not gaining traction. Although I kind of don't think it is I mean, I think a lot of people including me Feel that one eight seven is a little bit kind of neither here nor there. I mean it doesn't really It isn't really one point nine The purpose of it is to help you migrate to one point nine I I don't feel the need for that I feel like when when and if I want to go to one point nine I just will when it's sort of ready. So so I I mean I have I think actually preview two or something of one eight seven Installed and I've seen you know, I've seen it and so on but I don't actually use it in practice How many of you have one point nine of some version as your kind of day-to-day ruby? How many of you have it installed and have played around with it and stuff? Some okay One point nine It's actually incredibly difficult to get a fix on the question of whether one point nine is really a kind of release You know kind of production release or whether one point nine point anything is going to be a production release Whether I mean originally I think we all thought it was just a development release toward 2.0 It feels to me more like one point nine point one is Going to be production ish, I think But like I said, I I've actually had some trouble getting a fix on that But it's something you know, it's not it's not for lack of people Working on it and so on and we'll I think we'll find out more Now I'm going to talk about the future But actually this is as I said that the president and the future kind of slip into each other and in this case I'm really going to talk about one point nine mostly and because two point oh is Is you know is it is way in the future and I actually don't really know when it's I mean I have no idea when it's going to exist or exactly how it's going to relate to one point nine So one I think of one point nine is kind of the present But also the stuff that you do in one point nine that's different from one point eight is definitely Ruby of the future ish I mean it's that stuff is there because it's going to be there in in two point oh and so forth So it's I think reasonable to look at one point nine as as a harbinger of the future and again I think the jury's out on whether one point nine itself is going to sort of take root as a production Release in at some point, but but it's certainly you know, it's the sort of post one point eight world Now I wanted to go into actually some you know some pretty Specific technical things and you know partly just for the fun of seeing some of them Some of them may be things that that you've seen before or you haven't I'll probably if you haven't seen some of this stuff I'll probably be you know to some extent in some cases showing you more than you're going to sort of you know memorize on the spot or whatever but still just kind of you know Just have a look at it and it'll give you I think some signposts as you look yourself at one point nine and onward later and These are the five things that I want to talk about the new enumerable methods. I want to talk about enumerators Which I think are really key Something called basic object the lambda literal constructor the otherwise known as this the stab. What is it the stab? stabby thing anyway, you'll see and block variable scoping now New enumerable methods basically and again you don't I'm not expecting you to memorize this obviously But you know I did this partly as kind of notes to self and and decided to have it as a slide But what you see on the left is basically a list of methods that are in enumerable for In the enumerable module for one point nine that that are not there in one point eight So those are all new a couple of them are aliases of things that were there already But a lot of them are not and what you're seeing is a lot of new kind of functional ways to program collections like You know each cons for example the the fifth one on the list where if you have an array and you say each cons and Well actually without an n I think it defaults to two I hope so or my example is wrong But you can say each cons three or whatever and it will it will move across the collection kind of looking at or yielding to you a Sub collection consisting of that many elements and moving one at a time So if you're if your array is just the numbers one through ten It will yield one two three then it will yield two three four three four five and so on so it sort of moves one At a time but yielding and at a time in in an array There's reverse each which is kind of what it sounds like And that's just for if I mean obviously you can say dot reverse dot each but having a reverse each Makes it more or possible to implement it more efficiently and and so forth and a bunch of ones involving minimum and maximum values So there's quite a bit. Oh, yeah cycle the second one here cycle will iterate through a collection forever And I know there's a use case somewhere I can't remember it, but yeah, I mean it basically will just kind of keep going through it So I mean you can actually use that as a kind of you know like zip operation gone mad and so forth What's that? Yeah, right. That's right All right, a little bit about enumerators the reason I'm I'm gonna dwell a bit on on this topic because I Think again kind of playing the percentages, you know, some of you have probably looked how many of you have looked at in some depth at enumerators Okay, so my surmise all is probably correct then that most of you haven't right and yeah I mean enumerators are kind of there that you can actually require Enumerator in 1.8 and play with enumerators. They are there kind of for free in 1.9 and one of the reasons I want to talk about them is that I Have spent a fair amount of time getting my head into them And I thought it might be just good to Give you a head start on that process. I I mean I they make sense I I personally don't find them to be the simplest thing in Ruby by any means an enumerator is an object that First of all it is innumerable meaning it the enumerator class Mixes in innumerable. It's actually the innumerable Enumerator class so enumerators are innumerable, which means they have all that bundle of methods that comes from the innumerable module Select map Each reject inject and so on And every enumerator as befits an enumerable object every enumerator has an each method since all of this other stuff the Select and inject and so on is built on top of the iteration through the each method The difference or that the sort of thing about enumerators is that there each method is actually Another method well, it may be each or it may be some other method from another object in other words Enumerators to to enumerate or to iterate through that through their own each They actually kind of siphon the iteration values from a method on another object. That's why I call them somewhat parasitical And as for the efficiency we'll kind of see that play out as as we look at some examples But here okay, here's a more modern slightly more modern deck of cards I mean, it's very similar, but we have initialized essentially initialized just puts like, you know Two of hearts three of hearts four of hearts the actual strings I'm just saving 52 strings basically the something of something I'm not even really bothering with card objects or anything and then I Flatten that array and I shuffle it and then here's my my deal method I think it's not identical to the 1.0 example was basically the same idea. I have a hand or I'm dealing a hand, right? so I I will yield I'll yield each card as I go through If there's a block and in whether there's a block or not I will store the card in the hand array and then I return the hand array So if I say deal three for example, I'll get an array of three cards and the cards array That I'm actually popping them off the end. So the the cards array will be will be shortened by by n and Now why is it n equals card size? That's you don't usually deal the whole deck. Well, I guess you could if you Capture them in the block anyway It's unlikely but okay on the left you see what you see the cards Code that's the same code. Okay now here and on the right. I Create a new deck so it's going to have that cards array, you know two of hearts three of hearts and so on and Then I'm going to create an enumerator and this is In that second line where it says e equals deck That's my deck cards deck enum dot enum for deal now what I'm saying is I want an enumerator object that Whose idea of each in other words the idea of how this enumerator object is going to iterate is Basically to take values from the deal method of the deck of cards So for instance now Equipped with that enumerator I Can say for example hearts equals e and e is the enumerator e dot select card Card matches hearts a kind of brute force way to find hearts, right? And then if I print them out I get all the hearts that are in the deck So the enumerator when I say e dot select what it does And maybe this is why I did the whole card the whole deck. Um, what it does is It it knows that it's kind of hooked into it's like you're sort of hooking up the enumerator to a particular method on the object The method in this case is deal and the enumerator the each Method of the enumerator is hooked into the deal method of the deck So when when you trigger any kind of iteration on the enumerator What you're really doing is you're dealing the deck behind the scenes are the enumerator is actually Dealing from this deck so selecting from the enumerator ends up being as if I had selected from from the deal operation on the deck So Again here if I say debt it's very similar, but deck Enum for deal and then I throw another argument at it five It's what that's going to do is it's going to pass that five through to the deal Method So what happens is when I say to the enumerator Royals? I mean this is kind of you know It's their random since the deck is shuffled You know, it's not going to be the queen of hearts in the jack of spades every time But I say Royals equals e dot select card card matches j q Ka and here the enumerator's job is To deal me five cards in other words It knows that it's each method is hooked up to not only to the deal method But specifically to the deal method with an argument of five Now just a few I mean some of this is just kind of a little bit sort of reference But there's several ways to create enumerators. So really the third thing on this list is is the most important one In 1.9 when you call certain methods on enumerables like array dot map each Select a couple of others. I think You get back an enumerator now in the past when you called map without without I should say without a block Right when you called map without a block you would basically get back the Kind of neutral mapping you basically be like dupe You'd get back another array that just mapped the elements in your array to themselves If you did each without a block you would get your actual array but actually each always returned the receiver nowadays if you say For example Actually, so I don't have an exact example of that, but if you just say like some array dot map you'll get an enumerator and Again just a couple of other Examples of the kinds of things you can do with enumerators the main thing is just that the enumerator kind of carries around the knowledge of Another method on a not on another object or a method on another object that that it actually kind of proxies or represents So here if I've got days right Sunday through Saturday days Enum for map that means give me an enumerator on the map method of my array days It returns an enumerator and now if I say e dot each Day day upcase I get a mapping of the original array to the upcase values If you just looked from that line down and you just saw each You know you think well that shouldn't actually return a mapped array, you know this because each Basically involves side effects. I'm not actually doing anything in the blocks if you looked at they'd say wait That's not an each that's a map and it is a map because the each for this enumerator is hooked up to the map method For that array. Oh, sorry. Yeah, here's my examples without a block If you just say days again using the array days dot each days dot map and so on you now get or now Meaning in one point you will actually get enumerators back now Why do all this? partly it's You know why why return enumerators if you're going to do things well, but it's partly because it's kind of unused space most of the time you wouldn't Say just like array dot map or array dot each kind wouldn't serve much purpose You can also it since if map without a block returns an enumerator you can chain enumerators You can you can do another enumerator on that and also for efficiency reasons Enumerators create fewer intermediate objects, so again just about a little example of chaining if you say Select okay days dot select now that's going to return an enumerator if I stopped right there I'd get an enumerator, but I'd say days select dot with index What that's going to do with index is it is an enumerator method and that's going to cause to Objects to be yielded to my block on each iteration and you can see down there Basically, I say select and then I kind of I think if it's kind of laundering it through the with index And so instead of just giving me a day the days to select from it gives me the day and the index into the array I mean why I would want all the days that are indexed more than three well, whatever it's a kind of you know non-example but But that's the thing when you when you start to chain Iterators you see you know a little bit of the the the power of them oh This is just a cons example if you do it's actually it's It's pretty kind of thick and fast, but basically if you when you do that each cons to Operation again, I'm going to get kind of pairs walking through the arrays a Sunday Monday Monday Tuesday Tuesday Wednesday The way I did just display that is using the 2a or 2 array method Which is a good way just to get a kind of dump of what the enumerator thinks it's going to do when you ask it to do something so weekends is twos dot select and And from the from the pairs that are yielded to me the Sunday Monday Monday Tuesday, I select all the ones that have Either Saturday or Sunday, of course in Saturday and Sunday at opposite ends of the array Ironically, I don't actually get the weekend. I really just get the sort of half weekends But basically what I'm doing there again I'm saying that the object twos is an is an enumerator on The each cons method so now what it's kind of like pre pre cooking something It's like when I do an each on this it's already it already knows To lump the things into twos in other words It's that that each it's not just going to walk through a collection It's going to walk through a collection based on a particular method on that collection and there's actually going to going to Gallup a little bit through some of these because They're you know, they're kind of embellishments on what I've been saying and you certainly can can get these slides Actually, yeah, I want to get to the fun stuff I mean when you if you're interested in in looking at some of this more you can certainly get these slides but But just a couple of what I think a kind of fun enumerator Curiosities one of them is If I have Sorry an array of state abbreviations New Jersey and J. New York and so I just do a regular select I just want the ones whose abbreviations start with and So select state a bra right the ones that that match and or beginning in Now if I say in sort of the third stanza there if I say Oh, sorry one thing I wanted to point out here And this is another kind of tidbit that you might find useful in 1.9 When you do a select operation on a hash it returns a hash in 1.8. It returns an array 1.9. It returns a hash. That's just a kind of Refinement of that method that's that's happened. So in the third little bit when I say I want an enumerator for select and Then I run an each on that So I say e dot each state abbreviation abbreviation matches and and There again, it's sort of like a kind of a kind of cryptic each right if you just look at the each You you'd be like why is it why is it only returning to thing? You know like why is it using select logic if it's each reason is it's an each That's sort of hardwired to the select method For this for this enumerator The last example is a little convoluted so Yeah, and that's similar to what I did before where an each again each returns a Mapping one thing I another one that I find kind of amusing is if I do an enumerate I have my days array if I do an enumerator for map bang right map bang changes the thing in place So again, if you just looked at the third line, you know each day Day dot up case, you know it looks kind of odd, but not I mean you could say okay It's doing a mapping it must be an enumerator But here because it's it the enumerator is is hooked into map bang When I do the each through the enumerator it actually performs the in-place changes on the objects in the array So I consider that the stealth bang You know, it's like you kind of have to know it's there or your or your In trouble I would say with enumerators I mean again, you know, there's some some more there if you're interested in kind of the techniques and technical stuff But the bottom line with enumerators is they're kind of there They are kind of weird and you sort of have to accept as an axiom what they do and then let them kind of talk to you So to speak I mean there they're unlike to me that you know editorializing unlike iterators enumerators feel very kind of Engineered it's a dumb way to put by me iterators There's a certain kind of organic like you have an array and you go through it one at a time You know that kind of everything sort of flows from that enumerators are clearly kind of You know kind of the next Elaboration of that an enumerator again, it's just an object But it's an object with this kind of strange relation to another object. It's like, you know, I need an each You've got a select. I'm going to use your select as my each I mean that that's a like I say a kind of new embellishment on it But do you know as a as you look at some of this stuff and look at 1.9 and so on You'll you know, you'll see more of this in a lot of it's also in a bit influx, but But still it's it's interesting All right basic object Now basic object is a new thing in 1.9 and it's very similar to and I think owes some Perhaps of its existence to Jim Wyrick's blank slate class and the idea of the blank slate class and correct me if I misrepresent But the idea of the blank slate class in part is That there are times when you want an object that that has essentially no methods I mean it might have the absolute bear kind of survival kit of methods like underscore underscore sand or whatever and the reason you might want to do that is you might want to involve your objects in the development of let's say a DSL a domain specific language where you want The person using this language to be able to send pretty much any Message to this object and have the object not understand it now Why would you want to do that because then you can intercept it with method missing you can use the name of the method to do Something useful if the object already has a bunch of methods and you know kind of natively Ruby objects Actually quite a few Then it becomes harder, you know that the likelihood of kind of a name clash that somebody will come up with a method That exists is is greater so Basic object in ruby 1.9 If you well to start with if you ask for the ancestors of any class Leaving out read line, which is only there because of IRB I have string comparable object kernel and then at the very top of the hierarchy basic object So it's been planted at the very top of the object tree It doesn't mix in kernel. It doesn't mix in anything It's now as of 1.9 basic object is kind of the top thing and if you say, you know, okay basic objects basic object What are your methods now? That's interesting because instance methods isn't one of its. Oh, no, yeah Yeah, thank you So right so basically I want to know its instance methods, right and you can see there's very few of them I mean it is kind of just the the survival kit kind of and Like if I ask down there in ruby 1.9 if I oh, this is by the way is IRB 1.9 basic if if I ask for its object ID, it doesn't even know that right? It doesn't even have that I love the the hyzen blank object where in IRB you try to create a new basic object and It can't even show you the string representation of it because there's no it does create it But it can't there's no inspect method. So IRB gives you this error And I like that and again, you know the sort of why of this is you know partly like well Jim you I don't remember if you built blank slate for builder or around the same time or whatever but Basically the the kind probably the most well-known use of the blank slate Class and therefore, you know, I mentioned that in the same breath with basic object because it's very much the same thing but the main the best known use of it is in the builder class where in in Building XML templates and again, this is by Jim if you say, you know, you have your XML builder object and you say x dot name for example, it creates a name element a name tag As part of its output stream And then you can you can nest other, you know X X or X dot person and then inside Block for that X dot first name and so on so if you come up You know if you want XML elements that happen to be named things like, you know put S or object ID or something You have to have an object that doesn't already have those names Claimed So so blank slate is now. Yeah, I mean Basic object is as I say very similar to blank slate and is now part of the the language Alright Yes Yes, it's before everything. Oh, okay. Yeah, it's before kernel even Yes Oh Where I think that's the unary negative Right, it's the unary negation All right moving on The lambda literal constructor, how many of you like the lambda literal No, never mind. I don't mean to be I mean there's been a lot of it's it's been a somewhat sort of hot potato And We we grown about it on IRC a lot and so on that thing you see there and all right You know, I'm stacking the deck a little I you know instead of an example I just show you the line noise, you know, like as if that proves anything it doesn't really I happen to not like this and I know You know most of the time people say well It's you know similar to this and another language or whatever which is actually an argument that almost never carries that much weight just on its own with me, but But I don't know What in the in the premises yeah, yeah, well the reason the reason for it is That it gives you I put this kind of tersely here, but yeah, it gives you method argument syntax meaning What you you can do things like optional arguments, which you can't in the pipes in the block Syntax so this is all kind of the on the search for a way to have anonymous functions that use method argument semantics instead of block argument semantics Sorry The reason it's necessary if it is is the problem with And actually I wanted to switch to some live little IRB stuff to show you some of this block parameter Things which I think I do have time for so I actually kind of include this In it. Tell me if you are you seeing yes, you're seeing Yeah How's that? Still small okay, wait hang on is that good? It's can you see it? The heavy artillery now, let me just get maximum width going here Yeah, I wanted to show you actually to kind of switch into demo mode for some of this stuff which can include the now I just updated my Subversion of this today so since it's always changing I probably was stupid because it may do things differently from what I'm expecting but anyway, this is a 1.9 our IRB session and It should be Which one is the one that shows you Was it Ruby release isn't there one that no well anyway, it's today ish. Oh well Okay, so for example, um, oh Whoops, there we go So what is it? Okay Right nice and fresh All right, so probably two first. All right, so for example. Yeah, the reason you know you have this lambda thing So if I say like f equals stab, you know a b equals one and We'll just evaluate that to be See now I can say f call Three and that will give me one presumably f call three four and so on so yeah, that gives me optional arguments now the reason Hello What do you need to do? Oh, you're this is like font policing go away All right, so So right the reason that this is necessary for those you haven't followed the The discussions over over the years literally is if you have a block like you know, you go one two three blah each um If I want this is not a whatever just look at the block don't worry about what the thing is if I say a Oh, actually, let me do it this way if I if I do the normal, you know lambda if I say a B equals one B if I do it with the block The problem is that the parser Can't tell that that second pipe is not an ore So it might be b equals one or something right at the bitwise or whatever it's right Sorry Bang bitwise Yeah, right well that's one possibility, but I think Right, yeah, right. I mean the other way to get around it is it but I'm a little bit out of date But I think a few weeks who didn't Eric maher and Submit a patch that made this work. I think that maybe Yeah, yeah, I mean I think it's it there's a lot of talk about this and the most recent wave of talk started as some Objections or difficulties with this the lambda stab thing and kind of went into talking about Alternatives and I think There may might have been a patch that worked or was kind of getting to the point of working which which I would actually like because I Don't want to have to use the stab thing. I I don't know that I've had that many Occasions to need this kind but actually I mean like if you're doing a defined method operation and using a proc It's nice if the proc can have method argument semantics. It's the point You know you're using it to create a method So I agree with Matt's that it's an important thing to be able to do I just wanted to show you a couple of other things about 1.9 block Arguments now one of the most actually it let's go back to 1.8 for a minute one of the most sort of you know Famous or infamous things about Ruby that people come across is like if I say a equals one And then I say and this is 1.8 right one one two three four each a Put s. I mean it doesn't matter what happens in the block in the body of the block, right? So basically for for a in one two three four put as highs it prints high Four times it returns my original, you know the receiver. That's what each does basically But then I have a equal to four right in other words the the a That exists prior to the block is the same as the a in the block parameter list and basically the The the logic behind it or the rule behind it is that blocks use Assignment semantics that you're saying a equals when you put it between the pipes I am one of two people that I know of who don't think that's bad. The other is gi de coup So I'm in good company, but yeah, are there others who yeah I mean I always thought of you know not doing this is kind of a solution in search of a problem But I'm definitely in the minority man over the years Matz has said he thinks this is the worst mistake he made in designing Ruby and you know whatever anyway, I Don't however time moves on and now we're back in or we're forward in 1.9 and if we say a equals one and Then we go like this and Then we examine a we find that a is in fact still one now If we do this however if we say each x and again, these are just you know dinky examples to make the point But if in the block I say, you know a equals x times 10 Now because it's not a block parameter It now is the a from the outer scope And that's as it should be I mean you you want to be able to write a closure on The local environment right so to do that What's that? There was It was yeah 1.8 Now let's say you wanted let's make a one again, let's say You happen to use The variable a but you're not sure whether you have an a in the local scope And you don't want to risk clobbering it But it's not really a block parameter because you only need one and you've already got x if you put a semi colon in the parameter list Anything to the right of the semi colon will it's not It's not a block parameter in the sense. It's not going to be bound to anything that gets yielded. It's just a list of local variables I never had this I also feel like if you if you have to put You know if you don't know what your local variable is then how will you know that it's a good idea to protect it? I don't know. I mean Yeah, so now if I do this the a in the block obviously got changed But the a outside the block didn't because I explicitly said I want a protected a inside this block So that's you know, that's kind of the the change and it's It's been it's been demanded over the years by a lot of people. So like I said, it's not my thing You know, I don't really mind it the way it was. I kind of liked it I I do understand going back to the the stabby lambda thing I do understand the need for some way to do anonymous functions with method argument semantics I mean that that I think we do need in one version or another I kind of root for it not to be that kind of Line noisy one All right, well, we're getting we're getting close to I just wanted to quickly talk about a few things And some of them have probably emerged from from my talk anyway, but you know just if I could wave the magic wand What would I change? Well, guess what, you know, I mean, that's a little bit kind of cheap shot because you know I like I know there's a reason for it And I don't I haven't written the patch that makes it unnecessary so I can't really you know I can't really complain too much, but The thing is though, it's actually supposed to look like a lambda character. This is part of the problem. It Matt said it's a lambda character turned 45 degrees or something I don't know I I mean What I would probably well or what I would probably do is change the is use the lambda keyword Which is I know it's more characters, but I you know, I actually yeah I actually like key word and we have like lambda proc proc new we have ones to spare. Yes Without a method name yeah, that was something Dave Thomas brought up I think at Ruby Conf in San Diego a few years ago the idea of Just doing like deaf and then an argument list and that would just be an anonymous function I don't know what happened to that that I mean that got a well-deserved round of applause when he Suggested it and I don't know whether there's been any I Mean I have to assume that Matt's doesn't want to do it I don't remember if there's there'd been any, you know much talk about it So right this thing it always looks like an arrow no matter what All right again, I'm just taking cheap shots here because I because I have the stage though Who was I talking with last night about our couple nights to go about inject and reduce I like inject You know that we have enough inject does have kind of a cult following in one point nine You can use the word reduce instead Get rid of class very this is fun. I get to say all the stuff I want to of course we're not going to get rid of class variables. I've always hated them. I've never hesitated to say so Block awareness to enumerate that was from actually one of the slides that I kind of skipped over But I'm not going to go into that a great deal, but now this is one Jim you talked briefly the other day about the the fluent style with the dots and so on right weren't you talking about in in connection with flex mock and It's now I think kind of in the name of fluent style. It's now possible to put a dot on the next line so put as ABC carriage return dot up case and I really I have said I really don't like that. I it just it I Feel like when I get to the end of a line, I should kind of know like that line doesn't evaluate to ABC It's not like there's some default object that that dot will apply to but now there kind of is and I I don't know I'm I really don't I think no, I think the plus will be interpreted as a unary plus I What's the verdict? Yeah, I don't know Yeah, no this one is pretty much unto itself. I also like where you could do hashes with commas. That's gone I it was just quick to you know, I already like one two three four You can't make a hash can't do that anymore in one point nine symbols have become kind of string like You can sort them and I maybe you could sort them before I can't remember but you can upcase them and stuff I don't know. There's kind of creeping string is among symbols and I would you know, that's again This is all just kind of you know editorializing, but I that to me is a bit of a non great thing Right because IRB right does does the end of line So anyway, that's just some of my my little pros and cons But my real conclusion is that I really love Ruby and I'm gonna keep loving it and I hope you do too And like I said if you if there's any things in here that you want to go back to or look at, you know In more depth, they'll be available Somewhere and that's about it. Thank you very much