| s1 s2 |

s1 := 1234 asString.
s2 := 1234 asString.

s1 = s2. "true"
s1 == s2. "false"

s1 asSymbol = s2 asSymbol. "true"
s1 asSymbol == s2 asSymbol. "true"

(s1 class allInstances select: [:s | s = s1 ]) size. "2"
(s1 asSymbol class allInstances select: [:s | s = s1 asSymbol ]) size. "1"

[ #stringA = #stringB ] bench. "26,812,864 per second"
[ 'StringA' = 'StringB' ] bench. "3,492,987 per second"

Best regards,
Henrik

-----Original Message-----
From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of Ben 
Coman
Sent: Friday, April 8, 2016 3:23 AM
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
Subject: Re: [Pharo-users] Pharo-users Question about the symbols

A symbol is like a string, except that all symbols with the same value are in 
fact the same object; that is, every #hello symbol is the exact same object as 
every other #hello symbol.

See "identically equal" section here...
http://sdmeta.gforge.inria.fr/FreeBooks/ByExample/08%20-%20Chapter%206%20-%20Special%20Symbol.pdf

cheers, ben

On Fri, Apr 8, 2016 at 7:20 AM, Valentin Ryckewaert 
<valentin.ryckewa...@gmail.com> wrote:
> Hello everyone,
>
> i'm learning Pharo and i'm having difficulties to understand the 
> symbols, what are they? How are they different of the ByteString ? Why 
> are they usefull ?
> Why should I put #string where I can put 'string' ?
>
> Thanks in advance for your answer.
> Valentin Ryckewaert

Reply via email to