Technology Programming

New in 1.9.1: The String Index Operator

In Ruby 1.8, the string index operator, when passed a single integer, returned the ASCII value of the character at that location. For example, "test"[0] would return 116, the ASCII value of the character t.

This behavior has changed in Ruby 1.9 to become more consistent with the behavior of the other variants of the index operator. For example, "test"[0,2] returns the string "te", the first two characters of "test".

Why should the the single integer variant behave differently?

This has been changed in Ruby 1.9. The statement "test"[0] will return the single character string "t".

#!/usr/bin/env ruby# In Ruby 1.8, this will return 116 # In Ruby 1.9, this will return "t" puts "test"[0]

Related posts "Technology : Programming"

How LiteData Creates Better Sites For Their Clients

Programming

Contrastive analysis of methodologies of test design for functional testing

Programming

A Proper Diet That Is Filled With Healthy Fats Can Help You Lose Weight

Programming

How to Create an Array of Objects in PHP

Programming

How to read character information from the World of Warcraft servers.

Programming

7 Ways To Master Ayurvedic Medicine For Constipation Without Breaking A Sweat

Programming

Web Design Company Kolkata for Seamless Ecommerce Site

Programming

What Happened to "Borland Delphi"? What is CodeGear? What is Embarcadero?

Programming

How to Send Pages to iFrame

Programming

Leave a Comment