Simen Kjaeraas: > I'm trying to have this sort of code compile: > > //////////////// > struct Foo { > int data; > this(int n) { > data = n; > } > } > > void bar(Foo f) {} > > bar(3); > //////////////// > > Is this even possible?
There is a uncommon syntax that allows you to do it with a class, but I don't know why structs don't work here: class Foo { int data; this(int n) { data = n; } } void bar(Foo f ...) { assert(f.data == 3); } void main() { bar(3); } Bye, bearophile