www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ...cast or other?

reply Justin <stove31173 proton.me> writes:
...does 'to!real` relate to type-casting?
Mar 31
parent "H. S. Teoh" <hsteoh qfbox.info> writes:
On Tue, Mar 31, 2026 at 07:03:01PM +0000, Justin via Digitalmars-d-learn wrote:
 ...does 'to!real` relate to type-casting?
That's UFCS syntax for a function call to std.conv.to to convert something to a `real` value. In general using std.conv.to is arguably better than straight-up type-casting, even though internally that's what .to does, because .to also does range-checking and throws if the conversion is a truncating one and the target type would overflow. Not really applicable in this case, though, since you generally wouldn't overflow a `real` converting from another type. T -- Why is the pediatrician short-tempered? Because he has little patients.
Mar 31