Also there is a common approach to use the root as a counter of the one-level array using $seq(uence) or $I(ncrement). E.g.

Class Test.Arrays {

ClassMethod ArrayExample()

{

 set a($seq(a))="blue"

set a($seq(a))="red"

set a($seq(a))="yellow"

write a,!    // will return 3

zwrite a // will out the full array to the device

}

}

And if we execute the following in terminal you'll get:

USER>d ##class(Test.Arrays).ArrayExample()

3

a=3
a(1)="blue"
a(2)="red"
a(3)="yellow"

Also see the good article on $seq vs $I by @Alexander.Koblov

HTH

Hi, Ed!

Thanks! 

I'll elaborate the problem a bit. Here is the $case everybody loves:

write $case(condition, 1:expression1, 2:expression2, expression3)

My problem is that with business logic change the expression1 and expression2 showed the need for multiline logic. And I was looking for something like:

write $case(condition,

1: {

New cool logic for expression 1 with line 1
and line 2


},

2:{

Perfect, better logic for expression2
maybe with 
few lines
more

},

expression3)