JuliaLang/julia

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

Open

#44.410 aperta il 2 mar 2022

Vedi su GitHub
 (10 commenti) (4 reazioni) (0 assegnatari)Julia (5773 fork)batch import
good first issuestrings

Metriche repository

Star
 (48.709 star)
Metriche merge PR
 (Merge medio 20g 6h) (157 PR mergiate in 30 g)

Descrizione

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

Guida contributor