First time here? Check out the FAQ!
x

Array of Arrays (with variables)

0 votes
504 views
hello everybody, happy new year!

so, I have this expression:

 

| minor major  |
minor := #( 0 2 3 5 7 8 10 12).
major := #(0 2 4 5 7 9 11 12).
!Root +
(!Mode of: #(

{!Step of: major } {!Step of: major} ))

 

but as I run the sound, the Interprter tells me that major is undeclared.

what is my mistake?

thanks.

d
asked Jan 11, 2019 in Capytalk & Smalltalk by domenico-cipriani (Adept) (2,830 points)

1 Answer

0 votes
 
Best answer

It doesn't see the variable, major, because it is within curly braces, making it a literal. Try this slight rearrangement instead:

| minor major  |
minor := #( 0 2 3 5 7 8 10 12).
major := #(0 2 4 5 7 9 11 12).
!Root + 
(!Mode of: (Array with: (!Step of: major) with: (!Step of: minor) ))

answered Jan 11, 2019 by ssc (Savant) (115,600 points)
selected Jan 12, 2019 by domenico-cipriani
thanks a lot!
so, should variables never placed inside curly brackets?
Yes the curly braces mean "literal" so everything inside those braces is considered constant and unchanging. That's why there cannot be any variables inside.
...