January 17, 2014 chaining immutable methods vs functions | ||||
---|---|---|---|---|
| ||||
Why do I get the error message: Error: immutable method fbool.fbool.and is not callable using a mutable object when chaining methods? It works fine using regular function calls? struct fbool { ubyte data; pure immutable fbool and(immutable fbool b){return b.data < data ? b : this;} pure immutable fbool or(immutable fbool b){return b.data > data ? b : this; } pure immutable fbool not(){ return fbool(data^255);} } immutable fbool not(immutable fbool a){ return fbool(a.data^255); } immutable fbool and(immutable fbool a, immutable fbool b){ return a.data < b.data ? a : b;} immutable fbool or(immutable fbool a, immutable fbool b){ return a.data > b.data ? a : b;} or(and(not(a),b),and(not(a),b)); //this works a.not().and(b).or( b.not().and(a) ); // this does not work |
January 17, 2014 Re: chaining immutable methods vs functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | On Friday, 17 January 2014 at 01:49:24 UTC, Ola Fosheim Grøstad wrote:
> pure immutable fbool and(immutable fbool b){return b.data <
Nevermind, I figured this out. immutable(fbool), not immutable fbool...
|
Copyright © 1999-2021 by the D Language Foundation