Search on Shared array and return

Ali Çehreli acehreli at yahoo.com
Mon Dec 2 19:24:23 UTC 2024


On 12/2/24 5:20 AM, Jimson wrote:

 > shared User FindUser(string username)

That 'shared' makes the FindUser function shared. (More accurately, 
makes it so that FindUser will be executed on a 'shared' object.) 
However, FindUser is not a member function.

By apologizing unnecessarily for D's occasional syntax weirdness :) the 
fix is the following:

shared(User) FindUser(string username)

Always try to put whatever is shared, const, etc. in parenthesis.

Ali



More information about the Digitalmars-d-learn mailing list