Question about arrays.

Bob Arning arning at charm.net
Fri Sep 6 22:05:35 UTC 2002


On Fri, 06 Sep 2002 18:57:59 -0300 "Francisco A. Lizarralde" <frankliz at argenet.com.ar> wrote:
>I have an Array with Fractions like this
>
>#((3/4) (2/3))
>
>If I inspect (3/4) I look that it is a Fraction.
>
>If I inspect the former Array, I look that it has two elements, but when
>I inspect the first element of it, I look that it is another Array with
>tree elements, like this
>
>#( 3 #/ 4) not a Fraction.
>
>Could anybody tell me, how I can solve this ?
>
>Thanks in Advance.

Francisco,

Using #() can create arrays of literals only - Floats, Integers, Strings and Symbols. The Fractions you see are the result of a messages send (the message #/ is sent to 3 with 4 as the argument). If you use the brace constructor, you'll get what you wanted

	a _ {3/4 . 2/3}.
	a collect: [ :each | each class] ====> #(Fraction Fraction)

Cheers,
Bob

P.S. your mailbox is disabled



More information about the Squeak-dev mailing list