On Tuesday, October 30, 2018 2:18:15 AM MDT Laurent Tréguier via
Digitalmars-d-learn wrote:
> On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote:
> > Hi, so if you have this piece of code:
> >
> > struct C {
> >
> > void f() {
> >
> > string[] others;
> > const string[] restArgs;
>
On Tuesday, 30 October 2018 at 11:23:48 UTC, aliak wrote:
Guess I could do that. But would there be a difference if I
just declared the restArgs as non const then? Given the
objective is "set this var to point to this thing and not allow
it to be set to point to anything else".
The
On Monday, 29 October 2018 at 22:05:16 UTC, H. S. Teoh wrote:
What exactly are you trying to accomplish? I.e., what
semantics do you want from modifying restArgs?
Trying to set restArgs to point to some data but only set it
once. Would require some sort of control flow analysis on the
On Tuesday, 30 October 2018 at 08:18:15 UTC, Laurent Tréguier
wrote:
On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote:
Hi, so if you have this piece of code:
struct C {
void f() {
string[] others;
const string[] restArgs;
foreach (i, arg; args) {
if
On Monday, 29 October 2018 at 22:12:24 UTC, Paul Backus wrote:
Use a lambda:
const string[] restArgs = () {
foreach(i, arg; args) {
if (isValidArg(arg)) {
return args[i+1 .. $];
}
others ~= arg;
}
}();
That works.
On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote:
Hi, so if you have this piece of code:
struct C {
void f() {
string[] others;
const string[] restArgs;
foreach (i, arg; args) {
if (isValidArg(arg)) {
restArgs = args[i + 1 .. $];
break;
}
On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote:
Hi, so if you have this piece of code:
struct C {
void f() {
string[] others;
const string[] restArgs;
foreach (i, arg; args) {
if (isValidArg(arg)) {
restArgs = args[i + 1 .. $];
break;
}
On Mon, Oct 29, 2018 at 09:50:32PM +, aliak via Digitalmars-d-learn wrote:
> Hi, so if you have this piece of code:
>
> struct C {
>
> void f() {
> string[] others;
> const string[] restArgs;
> foreach (i, arg; args) {
> if (isValidArg(arg)) {
> restArgs = args[i