Should this work?
Manu
turkeyman at gmail.com
Thu Jan 9 07:13:53 PST 2014
On 10 January 2014 00:34, John Colvin <john.loughran.colvin at gmail.com>wrote:
> On Thursday, 9 January 2014 at 14:08:02 UTC, Manu wrote:
>
>> This works fine:
>> string x = find("Hello", 'H');
>>
>> This doesn't:
>> string y = find(retro("Hello"), 'H');
>> > Error: cannot implicitly convert expression (find(retro("Hello"),
>> 'H'))
>> of type Result!() to string
>>
>
> In order to return the result as a string it would require an allocation.
> You have to request that allocation (and associated eager evaluation)
> explicitly
>
> string y = "Hello".retro.find('H').to!string;
>
Ah yes. Well I really just want the offset anyway...
However, I think to get the expected result from unicode you need
>
> string y = "Hello".byGrapheme.retro.find('H').to!string;
>
> but I might be wrong.
>
Bugger that. This is not an example of "D is good at strings!".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140110/8b783f5c/attachment-0001.html>
More information about the Digitalmars-d
mailing list