Nice const array messages. Thanks!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Nice const array messages. Thanks!

Anthony Walter-3
I just noticed this really nice compiler feature. I don't know when it as added but it's really helpful.

When defining const array like below the compiler will tell you how many elements are missing:

  Food: array[0..7] of string = (
    'Apple', 'Banana', 'Cherry', 'Doughnut', 'Eclair');  

Error: Expected another 3 array elements

And when you have too few elements in the array in it will make tell you the point where it expected the array to end.

  Food: array[0..2] of string = (
    'Apple', 'Banana', 'Cherry',| 'Doughnut', 'Eclair');  

Fatal: Syntax error, ")" expected but "," found, 

And in Lazarus the caret is placed where the array should have ended "|".

This is really great feature and helps a lot when declaring array constants with many items. Thank you to whomever added this to the compiler :)

fpc-pascal maillist  -  [hidden email]