Skip to content

Commit 66a7df7

Browse files
committed
Add get(string, index, default)
1 parent 0737032 commit 66a7df7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

base/strings/basic.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ getindex(s::AbstractString, v::AbstractVector{<:Integer}) =
3939
getindex(s::AbstractString, v::AbstractVector{Bool}) =
4040
throw(ArgumentError("logical indexing not supported for strings"))
4141

42+
get(s::AbstractString, i::Integer, default) = start(s) <= i <= endof(s) ? s[i] : default
4243
Symbol(s::AbstractString) = Symbol(String(s))
4344

4445
"""

0 commit comments

Comments
 (0)