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
#4415
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  
Character Encoding


The default character set for Ruby is ASCII, whose characters may be represented by single bytes.

If we use UTF-8, or another modern character set, characters may be represented in one to four bytes.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4416
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  
String Built-in Methods:

We need to have an instance of String object to call a String method.


Following is the way to create an instance of String object:


new [String.new(str="")]
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4417
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  
Following is the way to create an instance of String object:

new [String.new(str="")]


This will returns a new string object containing a copy of str.

Now using str object we can all any available instance methods
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4418
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  
Lets understand some of the public String methods

.We are assuming that str is a String object .

1. str % arg


Formats a string using a format specification. arg must be an array if it contains more than one substitution.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4419
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  
2. str * integer

Returns a new string containing integer times str. In other words, str is repeated integer imes.


3 str + other_str

Concatenates other_str to str.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4420
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  
4. str << obj

Concatenates an object to str. If the object is a Fixnum in the range 0.255, it is converted to a character. Compare it with concat.


5 str <=> other_str

Compares str with other_str, returning -1 (less than), 0 (equal), or 1 (greater than). The comparison is casesensitive.
 
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