Re: Using a tuple as a function parameter

2024-11-29 Thread Harry Parker via Digitalmars-d-learn
Using a tuple as a function parameter allows you to pass multiple values as a single argument while maintaining their immutability. For example: python def example_function(data_tuple): for item in data_tuple: print(item) example_function((1, 2, 3)) This ensures effic

Re: Using a tuple as a function parameter

2024-11-29 Thread Harry Parker via Digitalmars-d-learn
Hello

Re: Using a tuple as a function parameter

2024-11-23 Thread IchorDev via Digitalmars-d-learn
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote: I'm getting started using D for some small personal projects and one thing I wanted to do was use a helper function for a tuple. I declared the function like this: string getOrZeroth(Tuple!(string, string, string) tup, int i) pure

Re: Using a tuple as a function parameter

2024-11-22 Thread Paul Backus via Digitalmars-d-learn
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote: I'm getting started using D for some small personal projects and one thing I wanted to do was use a helper function for a tuple. I declared the function like this: string getOrZeroth(Tuple!(string, string, string) tup, int i) pure

Re: Using a tuple as a function parameter

2024-11-22 Thread Andy Valencia via Digitalmars-d-learn
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote: I'm getting started using D for some small personal projects and one thing I wanted to do was use a helper function for a tuple. I declared the function like this: string getOrZeroth(Tuple!(string, string, string) tup, int i) pure

Re: Using a tuple as a function parameter

2024-11-22 Thread monkyyy via Digitalmars-d-learn
On Friday, 22 November 2024 at 17:24:08 UTC, Inkrementator wrote: Tuple access seems to be internally coded as a template (with unusual syntax) Its been a while since Ive tolerated std.tuple, is there any unusual syntax?

Re: Using a tuple as a function parameter

2024-11-22 Thread Inkrementator via Digitalmars-d-learn
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote: Error: variable \`i\` cannot be read at compile time Tuple access seems to be internally coded as a template (with unusual syntax) for the reasons already said. `i` has to be known at compile time for this to work, so a template param

Re: Using a tuple as a function parameter

2024-11-22 Thread user1234 via Digitalmars-d-learn
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote: I'm getting started using D for some small personal projects and one thing I wanted to do was use a helper function for a tuple. I declared the function like this: string getOrZeroth(Tuple!(string, string, string) tup, int i) pure

Re: Using a tuple as a function parameter

2024-11-22 Thread monkyyy via Digitalmars-d-learn
On Friday, 22 November 2024 at 16:36:43 UTC, Andrew wrote: I'm getting started using D for some small personal projects and one thing I wanted to do was use a helper function for a tuple. I declared the function like this: string getOrZeroth(Tuple!(string, string, string) tup, int i) pure