用法一
replace!(A, old_new::Pair...; [count::Integer])对于 old_new 中的每一对 old=>new ,将集合 A 中所有出现的 old 替换为 new 。使用   确定相等性。如果指定了isequal count,则总共最多替换count。另见 。replace 
例子
julia> replace!([1, 2, 1, 3], 1=>0, 2=>4, count=2)
4-element Vector{Int64}:
 0
 4
 1
 3
julia> replace!(Set([1, 2, 3]), 1=>0)
Set{Int64} with 3 elements:
  0
  2
  3用法二
replace!(new::Function, A; [count::Integer])将集合 A 中的每个元素 x 替换为 new(x) 。如果指定了 count,则最多替换 count 值(替换定义为 new(x) !== x )。
例子
julia> replace!(x -> isodd(x) ? 2x : x, [1, 2, 3, 4])
4-element Vector{Int64}:
 2
 2
 6
 4
julia> replace!(Dict(1=>2, 3=>4)) do kv
           first(kv) < 3 ? first(kv)=>3 : kv
       end
Dict{Int64, Int64} with 2 entries:
  3 => 4
  1 => 3
julia> replace!(x->2x, Set([3, 6]))
Set{Int64} with 2 elements:
  6
  12相关用法
- Julia replace()用法及代码示例
- Julia replace方法用法及代码示例
- Julia repeat方法用法及代码示例
- Julia repeat用法及代码示例
- Julia repr方法用法及代码示例
- Julia repeat()用法及代码示例
- Julia rem用法及代码示例
- Julia reduce方法用法及代码示例
- Julia redirect_stdio用法及代码示例
- Julia readchomp用法及代码示例
- Julia readuntil用法及代码示例
- Julia real方法用法及代码示例
- Julia readlines用法及代码示例
- Julia retry用法及代码示例
- Julia read用法及代码示例
- Julia reverseind用法及代码示例
- Julia reim用法及代码示例
- Julia readline用法及代码示例
- Julia reverse!用法及代码示例
- Julia reshape用法及代码示例
- Julia reverse方法用法及代码示例
- Julia resize!用法及代码示例
- Julia readeach用法及代码示例
- Julia reverse()用法及代码示例
- Julia rest用法及代码示例
注:本文由纯净天空筛选整理自julialang.org 大神的英文原创作品 Base.replace! — Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
