"Approx-equal" operator

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Sun Dec 18 10:43:56 PST 2011


On 17.12.2011 21:22, Sam Ruby wrote:
> On Sat, Dec 17, 2011 at 6:12 AM, Dmitry Soshnikov
> <dmitry.soshnikov at gmail.com>  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.


More information about the es-discuss mailing list