On Tuesday, 7 April 2015 at 15:51:59 UTC, bearophile wrote:
tcak:
void dataProcessor( string giveMeAllYourData ){}
dataProcessor( cast( immutable )( importantData[5 .. 14] ) );
With Const,
void dataProcessor( in char[] giveMeAllYourData ){}
dataProcessor( cast( const )( importantData[5 ..
tcak:
void dataProcessor( string giveMeAllYourData ){}
dataProcessor( cast( immutable )( importantData[5 .. 14] ) );
With Const,
void dataProcessor( in char[] giveMeAllYourData ){}
dataProcessor( cast( const )( importantData[5 .. 14] ) );
Don't cast to const/immutable unless you have a g
If you're just looking at the data, use const. immutable becomes
more important if it is shared across threads or stored for later.
Functions that accept const will work with almost anything you
pass to it.
On Tuesday, 7 April 2015 at 15:11:39 UTC, tcak wrote:
I have data in memory, and I want a function to take a part of
data for processing only. It will only read and won't change.
char[] importantData;
With Immutable,
void dataProcessor( string giveMeAllYourData ){}
dataProcessor( cast( immu