Skip to content

map(f, ::String) requires f to return an AbstractChar #54580

Open
@Seelengrab

Description

As seen on discourse.

MWE:

julia> '' |> UInt32
0x00003042

julia> map(UInt32, "あいうえお")
ERROR: ArgumentError: map(f, s::AbstractString) requires f to return AbstractChar; try map(f, collect(s)) or a comprehension instead
Stacktrace:
 [1] map(f::Type{UInt32}, s::String)
   @ Base ./strings/basic.jl:669
 [2] top-level scope
   @ REPL[5]:1

This should IMO return a Vector{UInt32} instead. The original error was added in f08ba8d; the commit also has a comment already mentioning that it would be good not to be too restrictive here.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions