On 17.12.2011 21:22, Sam Ruby wrote:
On Sat, Dec 17, 2011 at 6:12 AM, Dmitry Soshnikov
<[email protected]>  wrote:
And the other thing is "RegExp-substringing" with using bracket notation:
string[RegExp, startIndex].

"ecmascript"[/ecma/, 0]; // "ecma"

This is actually the sugar for:

"ecmascript".match(/ecma/)[0]; // "ecma"
In Ruby it is more than just sugar.  The results can be used on the
left hand side of an assignment statement.

string='The quick brown fox jumped'
string[/\s\w(\w)\w\s/,1] = 'O'
puts string

produces "The quick brown fOx jumped"

Yes, this is because strings in Ruby are mutable. But not in ES.

Dmitry.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to