On Fri, Aug 13, 2010 at 5:03 PM, Sven Van Caekenberghe <sven@beta9.be> wrote:

On 13 Aug 2010, at 14:03, laurent laffont wrote:

> On Fri, Aug 13, 2010 at 12:55 PM, St��phane Ducasse <stephane.ducasse@inria.fr> wrote:
> send them the code for pharo :)
>
>
> Kata for better code ? (sorry German)
>
> |md5 url|
> md5 := MD5 new hashStream: (ReadStream on: 'gsa@arsol.net').
> url := ��String streamContents: [:aStream|
> �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� aStream nextPutAll: 'http://www.gravatar.com/avatar/'.
> �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� md5 do: [:aByte|
> �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� aStream nextPutAll: aByte hex asLowercase]].
> (ImageMorph fromStream:
> �� �� �� (url asUrl retrieveContents contentStream)) openInWorld.
>
> Laurent

I really like code that speaks for itself, like this example !
Great, Laurent.

It can even be written shorter, like this:

| md5 url |
md5 := MD5 hashMessage: 'gsa@arsol.net'.
url := ('http://www.gravatar.com/avatar/', md5 hex) asUrl.
(ImageMorph fromStream: url retrieveContents contentStream) openInWorld.




I was looking for such brevity, cool !

Laurent




��

Sven


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project