JuliaLang/julia

Unexpected behavior due to implicit `convert` with `Char` and `Integer`

Open

#44,410 opened on Mar 2, 2022

View on GitHub
 (10 comments) (4 reactions) (0 assignees)Julia (5,773 forks)batch import
good first issuestrings

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (Avg merge 20d 6h) (157 merged PRs in 30d)

Description

julia> append!([1, 2, 3], "4")
4-element Vector{Int64}:
  1
  2
  3
 52

is unintuitive (I would expect an error).

I think the mechanism for this is that it treats the "4" as a collection of Chars, and converts them into integers.

cc @jakobnissen @andrewrosemberg @raphaelsaavedra

Contributor guide