toLower
FeepingCreature
feepingcreature at gmail.com
Tue Aug 15 16:54:49 UTC 2023
On Tuesday, 15 August 2023 at 16:47:36 UTC, Joel wrote:
> How come toLower works in the sort quotes, but not in the map?
>
> ```d
> void main() {
> import std;
> "EzraTezla"
> .to!(char[])
> .byCodeUnit
> .sort!"a.toLower<b.toLower"
> .map!(c => c.toLower)
> .writeln;
> }
> ```
>
When you pass a string to a lambda, it's evaluated in
`std.functional.unaryFun`/`binaryFun`.
At that point, these modules are imported for use in string
expressions:
```
import std.algorithm, std.conv, std.exception, std.math,
std.range, std.string;
import std.meta, std.traits, std.typecons;
```
And `std.string` itself publically imports:
```
public import std.uni : icmp, toLower, toLowerInPlace, toUpper,
toUpperInPlace;
```
But does *not* import `std.ascii`! So there's no ambiguity inside
the `sort` string expression between the two `toLower` functions..
More information about the Digitalmars-d-learn
mailing list