Black Bytes » Jesus Castello http://www.blackbytes.info Ruby Programming Tutorials Tue, 15 Mar 2016 15:43:05 +0000 en-US hourly 1 http://wordpress.org/?v=4.3.3 My New Favorite Enumerable Method http://www.blackbytes.info/2016/03/enumerable-methods/ http://www.blackbytes.info/2016/03/enumerable-methods/#comments Mon, 07 Mar 2016 17:15:33 +0000 http://www.blackbytes.info/?p=2637 Enumerable is an amazing module, and it’s a big part of what makes Ruby such a great programming language. Enumerable gives you all sorts of cool methods like map, select and inject. But my new favorite is each_cons. This method is really useful, you can use it to find n-grams or to check if a […]

The post My New Favorite Enumerable Method appeared first on Black Bytes.

]]>
http://www.blackbytes.info/2016/03/enumerable-methods/feed/ 4
Exploring MRI Source Code http://www.blackbytes.info/2016/02/exploring-mri/ http://www.blackbytes.info/2016/02/exploring-mri/#comments Tue, 16 Feb 2016 21:39:56 +0000 http://www.blackbytes.info/?p=2604 If you have been using Ruby for a while you are probably curious about how some things work under the hood. One way to dig deep into Ruby internals is by reading the source code that makes it work. Even if you don’t know C, you can still pick up some interesting things. A great […]

The post Exploring MRI Source Code appeared first on Black Bytes.

]]>
http://www.blackbytes.info/2016/02/exploring-mri/feed/ 5
The Ultimate Guide to Blocks, Procs & Lambdas http://www.blackbytes.info/2016/02/ruby-procs-and-lambdas/ http://www.blackbytes.info/2016/02/ruby-procs-and-lambdas/#comments Tue, 02 Feb 2016 18:26:17 +0000 http://www.blackbytes.info/?p=2561 Understanding Blocks Blocks are very prevalent in Ruby, you can think of them as little anonymous functions that can be passed into methods. Blocks are enclosed in a do / end statement or between brackets {}, and they can have multiple arguments. The argument names are defined between two pipe | characters. If you have […]

The post The Ultimate Guide to Blocks, Procs & Lambdas appeared first on Black Bytes.

]]>
http://www.blackbytes.info/2016/02/ruby-procs-and-lambdas/feed/ 11
11 Ruby Tricks You Haven’t Seen Before http://www.blackbytes.info/2016/01/ruby-tricks/ http://www.blackbytes.info/2016/01/ruby-tricks/#comments Mon, 18 Jan 2016 20:40:35 +0000 http://www.blackbytes.info/?p=2491 1. Deep copy When you copy an object that contains other objects, like an Array, only a reference to these objects is copied. You can see that in action here: [crayon-56ed73b33a5cb609966278/] Using the Marshal class, which is normally used for serialization, you can create a ‘deep copy’ of an object. [crayon-56ed73b33a5e0764427572/] The results: [crayon-56ed73b33a5ea490133184/] 2. […]

The post 11 Ruby Tricks You Haven’t Seen Before appeared first on Black Bytes.

]]>
http://www.blackbytes.info/2016/01/ruby-tricks/feed/ 20
Understanding Mutable Objects & Frozen Strings http://www.blackbytes.info/2016/01/ruby-mutability/ http://www.blackbytes.info/2016/01/ruby-mutability/#comments Sun, 03 Jan 2016 18:32:22 +0000 http://www.blackbytes.info/?p=2427 Let’s talk about mutability. What does it mean for an object to be mutable? Don’t let the fancy word deceive you, it just means that the object state can be changed. Not all objects in Ruby are mutable, for example, it doesn’t make any sense for numbers or symbols, or even true or false (which […]

The post Understanding Mutable Objects & Frozen Strings appeared first on Black Bytes.

]]>
http://www.blackbytes.info/2016/01/ruby-mutability/feed/ 4