Featured
-
How Regression Testing Detects Integral Errors In Business Processes
Humans are forever changing and evolving and so to
by kristina.rigina -
Get Display Banner Advertising Opportunity on FindNerd Platform
“Do you have a product or service that nee
by manoj.rawat -
Android O Released with Top 7 New Features for App Developers
Android was founded by Andy Rubin, Rich Miner, Nic
by sudhanshu.tripathi -
Top 5 Features That Make Laravel the Best PHP Framework for Development
Laravel is a free open source Web Framework of PHP
by abhishek.tiwari.458 -
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi
Tags
using return keyword within a Ruby block
As we all know,Ruby Blocks and Ruby Methods work in tandem and the output/value of the last line/expression being executed by the block is returned to the associated method .
Have a look at this example:
2.1.5 :006 > def demo
2.1.5 :0...
Implicit and Explicit Blocks in Ruby
Blocks are basically a group of code that can be stored in a parameter and can be executed. There are majorly two ways of doing this:
1) Implicit:
In implicit, it is a nameless block and it is not passed as a parameter, it is exec...
Ruby Blocks
As we all know,Ruby Blocks and Ruby Methods work in tandem as clearly elucidated by the below example:
def demo_method
yield "hello"
end
demo_method { |block_argument| "#{block_argument}!! our first ruby blog"}
here, the ...
Blocks in Ruby
A block is a chunk of code that we put inside do..end or {}. You can use any of the both ways. But multiline block (do..end) is preferred over inline({}) block.
Example of block:
multiline style#
["red", "green", "yellow"].ea...
Sort an array of strings based on length of its elements in Ruby
In ruby if you want to sort an array of strings based on the length of its element, you can use the code given below. i.e If you want the word having the least number of characters in it to come first and arrange other words in this manner as w...