Creating Anonymous structs
    Alex 
    AJ at gmail.com
       
    Sat May 18 15:59:05 UTC 2019
    
    
  
Structs combine data, I have a use case where I do not want to 
litter the scope with variables and would like to put them in a 
struct but the variable will only be used once.
struct X
{
   int x;
   double y;
}
X x;
Seems redundant to have to do this, rather, it would be nice to do
auto x = struct {
   int x;
   double y;
};
And this would create the same effect but it would only exist in 
one place.
Is there any way to accomplish this without actually defeating 
the purpose?
Obviously there is not a huge difference between what is possible 
and what I want to achieve. I just feel it would be more sound to 
use an anonymous struct.
    
    
More information about the Digitalmars-d-learn
mailing list