Get more idea about the block, proc, lambda and currying in Ruby.

Photo by emy on Unsplash

Let’s dive-in into what blocks, procs and lambdas are and how to use them.


Blocks are the most common way to pass around references to functions in Ruby. They open the door to some classy looking DSLs by making it super easy and readable to pass functions as arguments, example:

You can pass block as an argument via either passing it into a curly braces {} or capsulate it in do..end.

Block format 1:

array = [1,2,3,4] do |ele|

Block format 2: { |ele| do_something }

While you are in a method how can you know…

Let’s explore functional thinking and what it entails wrt Ruby.

Photo by Valeria Bold on Unsplash

We all know that Ruby is an Object-oriented language, and while that’s true we can still use Ruby in a purely functional way. It won’t be much Rubyish if we did that though, so let’s see what bits we can do with Ruby that are inspired from functional programming.

Functional programming is essentially like writing a mathematical program. Let’s understand this with an example, consider that I want to find out first odd number in an array. Now we will write two functions with same objective, one in Ruby way, another in a functional way.

# Ruby way
def first_odd(array)…

Back to Basics |Write Better Code

“Good design adds value faster than it adds cost.”

This article will cover what SOLID principles are in detail and why we should use them. As we all know, code tends to evolve over time, we write it, and then we come back to it to modify it, to tweak it, to fix bugs — and well-designed code is just so much easier to come back to — because over time bad code becomes harder and harder to maintain. Hence spending time on designing good code will save costs and efforts in the future.

Ruby is an object oriented programming language.

Now for the uninitiated let’s start with the beginning. To understand the concept of a class let’s take an example of a real world physical entity, a dog, which will represent a class. There can be many dogs with same behaviour(or states). Now, you can take one dog in particular, let’s say tommy

tommy =“tommy”)

Now tommy is an instance or an object of a the class Dog, because it has all the behaviours of that class. A dog has 5 possible behaviours: eat, sleep, walk, bite & woof. …

Storytelling is a way to connect with others, it will help you inspire, lead, create an impact on others, and much more.

In this article, we will look into how to become a better storyteller by compressing stories into bite-sized pieces, making ideas more interesting by telling them in simple lessons. We’re going to learn about how to inspire your audience, how to increase engagement, tips, and practical tools for creating authenticity. Let’s dig in.

Start with the why

Simon Sinek coined this philosophy in his book Start With Why. It’s about how great leaders inspire action by starting with…

One day I stumbled upon this awesome site called “Exercism”. It mainly focuses on improving your skills via Deep Practice & Crowdsourced Mentorship, Strengthening your problem-solving skills by guiding others through the process.

I got hooked onto it and then I thought why not share my learning with all. Being a Ruby programmer, my notes are Ruby based.


Before tackling any program/problem/challenge you should keep certain points in your mind. Some are general, some are more language specific.

Some questions you might want to ask yourself:

  1. Am I adhering to the Single Responsibility Principle?
  2. Is all my code on the same abstraction level?
  3. Can I combine conditional clauses?
  4. How does my API look to clients of this code (i.e. how do other classes interact with this class)?
  5. Do I have duplication?
  6. What requirements…

Pull out the wildest twig of your lesser known self and imagine — A small kid whirling around farms, treasuring and savoring raw mangoes, slinging mud shots in all possible directions(oops someone got hit!!), transforming into a plane with winds, bantering around with friends, becoming an acrobat on cycle, getting some bruises ameliorated with turmeric latte and mom’s crossed eyes. Isn’t that kid one of us and those were some of the best memories of our childhood?? I would say these are one of the most revered memories of anyone’s life and obviously, that fails to exclude mine.
What if you…

Anjali Jaiswal

Programmer, avid Reader, artist, exploring different trades, fun-loving, adventurous and most of the time a hell-yes person!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store