Efficient way to create/copy immutable struct instance with modified data

2021-11-19 Thread Merlin Diavova via Digitalmars-d-learn
Hi all, I'm trying to figure out the most efficient way to create modified instances of immutable structs. Currently, I'm doing the following: ```d immutable struct Node { string label; Node parentNode; NetworkPort port; auto withLabel(string newLabel)

Re: Question on Immutability

2021-09-01 Thread Merlin Diavova via Digitalmars-d-learn
Goal achieved! Thanks all, really appreciate the assistance.

Question on Immutability

2021-08-30 Thread Merlin Diavova via Digitalmars-d-learn
Hi All, I'm trying to understand immutability in D and it seems a bit odd. I'm coming from dynamic languages so please forgive my ignorance and dynamic language-isms. I want to have a base `Project interface` and then extend other more specific interfaces from that such as `DockerEnabledProje

Re: A little help with Ranges

2021-08-26 Thread Merlin Diavova via Digitalmars-d-learn
On Friday, 27 August 2021 at 04:01:19 UTC, Ali Çehreli wrote: On 8/26/21 7:17 PM, Merlin Diavova wrote: [...] Then the operations downstream will not produce any results. For example, the array will be empty below: import std.stdio; import std.range; import std.algorithm; import std.string

Re: A little help with Ranges

2021-08-26 Thread Merlin Diavova via Digitalmars-d-learn
On Friday, 27 August 2021 at 02:10:48 UTC, Stefan Koch wrote: On Friday, 27 August 2021 at 01:51:42 UTC, Merlin Diavova wrote: Hi all, I'm Merlin, I'm just starting out in D and super excited. My questions are:- 1. In a range pipeline how does one handle the event of a filter range returning

A little help with Ranges

2021-08-26 Thread Merlin Diavova via Digitalmars-d-learn
Hi all, I'm Merlin, I'm just starting out in D and super excited. My questions are:- 1. In a range pipeline how does one handle the event of a filter range returning empty? 2. How does one unwrap a single result from a range operation? Look forward to your assistance! Merlin