question about property for built-in type

Denis Koroskin 2korden at gmail.com
Fri Oct 8 05:22:25 PDT 2010


On Fri, 08 Oct 2010 16:19:43 +0400, %u <djvsrose at gmail.com> wrote:

> Hi,
> I'm learning D right now and got a question about property.
> I tried to add a property for built-in type like the following
>
> @property bool equalZero(double a) { return a == 0.0; }
>
> void main()
> {
>   ...
>   double x = 4.4;
>   bool isXZero = x.equalZero;
>   ...
> }
>
> but got an error message
> main.d(75): Error: no property 'equalZero' for type 'double'
>
> I tried similar thing with int[] and it works.
> Is that I did something wrong or property does not support built-in type  
> like
> double, int, real, ...?
>
> Appreciate for your time and answer.
>

Uniform Function Call syntax (i.e. a.b(c) -> b(a, c)) only works for  
arrays atm. This may or may not be changed in future.


More information about the Digitalmars-d-learn mailing list