Sign up or Sign in | Share
 
ClearMyBench
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Ruby basics (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Ruby basics
#4433
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
str.replace(other_str)


Replaces the contents and taintedness of str with the corresponding values in other_str.


str.reverse

Returns a new string with the characters from str in reverse order.

str.reverse!

Reverses str in place.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4434
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Ruby arrays are ordered, integer-indexed collections of any object.

Each element in an array is associated with and referred to by an index.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4435
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Array indexing starts at 0, as in C or Java.

A negative index is assumed relative to the end of the array---that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array..
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4436
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Ruby arrays can hold objects such as String, Integer, Fixnum, Hash, Symbol, even other Array objects.

Ruby arrays are not as rigid as arrays in other languages.

Ruby arrays grow automatically while adding elements to them.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4437
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
There are many ways to create or initialize an array.

One way is with the new class method:

names = Array.new
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4438
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
We can set the size of an array at the time of creating array:

names = Array.new(20)

The array names now has a size or length of 20 elements.

we can return the size of an array with either the size or length methods:
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop
logo footer   Copyright 2009 - 2013 HotRecruiter.Com - All Rights Reserved