Can Spring4D save me from this ?
I just see a bunch of static arrays - how does spring4d come into play here?
The bottom line doesn’t work, and I want a short, elegant way to initialise the array.
Ah yes, that issue - typed const are no real const for the compiler and thus cannot be used in const array. You need to declare those directly in steps3.
You might want to try const instead of var.
I am too lazy to type it out myself if you only post pictures with code ![]()
Yes. I had tried const before I posted it
I need var for the working code with the initialisation deleted … so you get var. ![]()
But yes, variable initialization when it comes to arrays and records is terrible in Delphi ![]()
You can use a combination of type, const and var:
type TTuples = array[TDirection] of TupleInt;
const TupleInits: TTuples = ( (fst: ; snd: ), (...) );
var step: TTuples := TupleInits;
// Edit1: Or using type inference: var step := TupleInits;
// Edit2: And then you could also omit the type and just use:
// const TupleInits: array[TDirection] of TupleInt= ( (fst: ; snd: ), (...) );
// var step := TupleInits;
...
Ok ! Hell yeah. Thank you @Jarrod.
It hadn’t occurred to me to think of this, like in the way you might need to define a definite type to use in a function signature.
![]()


