On 9/22/14 10:07 PM, AsmMan wrote:
I have this array:

static immutable string[] months = ["jan", "fev", ...];

I need to pass it into canFind(). But it doesn't works with immutables
so I need to cast it like in canFind(cast(string[]) months, month) to
work. There's a reason related to design why it doesn't work with
immutables or a function just wasn't written?

What I want to know is if I'm doing something wrong in casting it to
work. I know from C which such casts should be done carefully

Yes, casting should be used very sparingly, and only when you have no other choice.

Ali suggests that the latest version of DMD on git handles this, but just an FYI, you do not need to cast to get a mutable array of strings:

canFind(months[], month)

should work.

-Steve

Reply via email to