It there a way to get this to compile?
a11e99z
black80 at bk.ru
Mon Sep 9 19:19:35 UTC 2019
On Monday, 9 September 2019 at 19:08:17 UTC, WhatMeWorry wrote:
>
> struct FoundationPile {
> Card[] up; // all cards are face up on the Foundation
> }
>
> FoundationPile[4] foundations;
>
> static if(true) {
> int r = 2;
> int c = 40;
> static foreach(i ; foundations) {
> immutable string brackets = "\033[" ~ to!string(r) ~
> ";" ~ to!string(c) ~ "H";
> c = c + 10; // line 155
> }
> }
NB
dont use name "i" for foreach/ranges,
foreach can be used with index too,
use "el" as "element" or "it" as "iterator" or just "something"
> static if(true) {
> enum r = 2, c = 40; // bad names too
> static foreach( idx, el; foundations) {
> immutable string brackets = "\033[" ~ to!string(r) ~
> ";" ~ to!string(c + idx*10) ~ "H";
> }
> }
More information about the Digitalmars-d-learn
mailing list