Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Arrays and Hash In Ruby

Ruby's arrays and hashes collections having indexes. They can also be said as indexed collections. Arrays and hashes store collections of objects which can be accessed using a key. Both arrays and hashes grow as needed to hold...

Iterators and its usage in ruby

In Ruby, iterators are methods basically used by the collections. Collections are a set of objects. Hashes & Arrays are the example of collections. Iteration is a process by which we can get or set the elements in collections. We will discuss...

split ,find_index , map and capitalize methods in Ruby

Strings in Ruby have an instance method namely split that splits the given String and returns an array of substrings based on the separator given as an argument to it. have a look at these examples: gauravjhadiyal@gauravjhadiyal:~$ irb 2...

find_all method in ruby.

The find_all method has to do with arrays in Ruby.This method simply iterates through all the elements in an array and meanwhile test each of them against a test condition and finally returns an array containing all elements for which the test re...

Array Conditions and selecting specific fields to find or retrieve from database (Active records)

Array Conditions and selecting specific fields to find or retrieve from database through Active records Array Conditions To retrieve some specific data from the database we use the where method which gets the records in the form o...

Array and operations on array

Array is used to keep collection of objects. Array in ruby can have any type of objects together. Using array in ruby: >> a = [] >> arr = [1, 0, 7] >> arr[2] # => 7 >> arr.size # => 3 >> arr = ["stri...

each, collect and map in ruby

1> 'each' will loop through each element of the array and evaluate whatever is return inside the block, but it returns the original array without any change. a = [5,10,15,20] => [5, 10, 15, 20] a.each {|t| t+2} => [5, 10, 15, 20...

Using reject in ruby to delete elements selectively from an array

1> To delete an element from an array, use reject as shown below: arr = ['a','b','c','d','e'] arr.reject! { |i| i.match('d')} Result :=> ["a", "b", "c", "e"] 2> To delete particular keys from the array whose elements are ...

Applying limit and offset to array

In rails we can apply limit and offset to arrays in different ways. 1> Using "slice" method. slice takes 2 arguments, the first one being the "starting_index" & the second one is the "number_of_elements". syntax :- arrayob...
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: