Why there is no documentation for `merge`

merge is a useful function. Why there is no documentation found for it in the julia command line.

Documentation is here : Collections and Data Structures · The Julia Language

julia> a                            
Dict{Int64, Int64} with 3 entries:  
  2 => 4                            
  3 => 6                            
  1 => 2                            
                                    
julia> b                            
Dict{Int64, Int64} with 4 entries:  
  4 => 10                           
  2 => 8                            
  3 => 9                            
  1 => 7                            
                                    
julia> c = merge(a,b)               
Dict{Any, Any} with 4 entries:      
  4 => [10]                         
  2 => [4, 8]                       
  3 => [6, 9]                       
  1 => [2, 7]
help?> merge
search: merge merge! mergewith mergewith! MergeSort

  No documentation found.

  merge is a Function.

  # 1 method for generic function "merge" from Main:
   [1] merge(d...)
       @ REPL[6]:1

I just tried it on 1.10.4 with the following result

help?> merge
search: merge merge! mergewith mergewith! MergeSort

  merge(d::AbstractDict, others::AbstractDict...)


  Construct a merged collection from the given collections. If necessary, the types of the resulting collection will
  be promoted to accommodate the types of the merged collections. If the same key is present in another collection,
  the value for that key will be the value it has in the last collection listed. See also mergewith for custom
  handling of values with the same key.

  Examples
  ≡≡≡≡≡≡≡≡

Are you satisfied with the documentation now or do you still need help?

I get many pages of documentation for merge, so it is available if working correctly.

I suspect that you have defined your own merge function. E.g. doing this in a fresh session gives the behavior you see:

julia> merge(d...) = first(d)
merge (generic function with 1 method)

help?> merge
search: merge merge! mergewith mergewith! MergeSort

  No documentation found.

  merge is a Function.

  # 1 method for generic function "merge" from Main:
   [1] merge(d...)
       @ REPL[1]:1
7 Likes

BTW this is an important clue: it means that the name merge refers to a function defined in Main (i.e. your code), instead of the name from Base. This is called shadowing, i.e. your name is shadowing that of the name from Base. If you do ?Base.merge you can get the documentation for Base.merge.

edit: Scooped by Gunnar :slight_smile:

10 Likes