# Is there Way to know methods/functions of classes(modules/functions)

**URL:** <https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [December 16, 2020, 6:30pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944 "2020-12-16T18:30:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vedasulo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vedasulo/32/20324_2.png) [@vedasulo](https://discourse.julialang.org/u/vedasulo)\
**Post date:** [December 16, 2020, 6:30pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/1 "2020-12-16T18:30:09Z")

</div>

For example,  
I’ve defined a array or anything,

```julia

a = [1,2,3,4,5]

```

as we have methods opposite order.

If I want to know what are the methods could be used in this array. looking _help_ on `a` doesn’t gives any methods to see.  
search: a any all abs ans Any axes atan asin asec any! all! acsc acot acos abs2

No documentation found in any defined datatypes or functions.

```julia

  a is of type Array{Int64,1}.

  Summary
  ≡≡≡≡≡≡≡≡≡

  mutable struct Array{Int64,1} <: DenseArray{Int64,1}

  Supertype Hierarchy
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  Array{Int64,1} <: DenseArray{Int64,1} <: AbstractArray{Int64,1} <: Any

```

It would be great if I would know some `code completion on methods` of some datatypes.

* * *

Also,  
I want to know how julia pushes/appends `arrays of array` like this `[1, 2, 3, 4, 5, [1,2,3]]`  
I cant use `push!(a, [1,2,3])` giving error `MethodError`. although  
this worked

```julia
a = [1,2,3,4,5]
append!(a, [1,2,3])

```

but appends like this `[1,2,3,4,5,1,2,3]`

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [December 16, 2020, 6:50pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/2 "2020-12-16T18:50:23Z")

</div>

`methodswith(typeof(a))` produces a list of methods that apply to `a`. But in this case you need the `supertypes = true` option (because most methods are defined on `AbstractArray` not on `Array`.

I doubt that the output is useful for types with many methods (1,800 in this case).

Code completion already works in the REPL. Start typing `issor` then hit tab and it completes to `issorted`, for example.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [December 16, 2020, 7:00pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/3 "2020-12-16T19:00:15Z")

</div>

```julia
julia> a = Any[1, 2, 3]
3-element Vector{Any}:
 1
 2
 3

julia> push!(a, [4, 5, 6])
4-element Vector{Any}:
 1
 2
 3
  [4, 5, 6]

```

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [December 16, 2020, 7:02pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/4 "2020-12-16T19:02:19Z")

</div>

> [@vedasulo](#):
>
> I cant use `push!(a, [1,2,3])` giving error `MethodError`

You cannot do this because:

```julia
julia> typeof([1, 2, 3])
Array{Int64,1}

```

So, `[1, 2, 3]` is a `Vector` that can be only used for `Int64` elements. If you want to have a `Vector` that allows both for `Int`s and `Vector{Int64}`s as elements, then you need to declare it as `Union{Int64,Vector{Int64}}[1, 2, 3]`. If you want the `Vector` to allow any type of elements you can do `Any[1, 2, 3]`. If you do not specify a type before the `[elem1, elem2, ...]`, then Julia will choose a valid element type for you. For example, if you already had `Int64`s and `Vector`s in the literal:

```julia
julia> typeof([1, 2, 3, [10, 20, 30]])
Array{Any,1}

```

---

<div class="post-metadata">

**Author:** ![vedasulo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vedasulo/32/20324_2.png) [@vedasulo](https://discourse.julialang.org/u/vedasulo)\
**Post date:** [December 17, 2020, 5:01pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/5 "2020-12-17T17:01:13Z")

</div>

Thank you hendri54 🙂 .

> [@hendri54](#):
>
> `methodswith(typeof(a))`

This solves problem of finding methods of them, although i wanted a different way.

But It is not interactive. Like those in other languages  
a. and `tab` gives alot of possible methods interactively but I didnt got , I wanted to get interactively find a way in julia.

I am thinking how julia is thinking to make it interactively to find methods, also without going to type `typeof` to every variables, like other languages does.

Yes I use tab if forgot some methods but it is arbitary to every and difficult to remember every classes methods .

but although this is ok for other peoples. 🙂

---

<div class="post-metadata">

**Author:** ![vedasulo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vedasulo/32/20324_2.png) [@vedasulo](https://discourse.julialang.org/u/vedasulo)\
**Post date:** [December 17, 2020, 5:09pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/6 "2020-12-17T17:09:21Z")

</div>

Thank you Henrique and @jiapeyre. This solves my first problem.  
In order to have `[1, 2, 3, 4, 5, [1,2,3]]` we have to convert `array to vector` and we’ll get solved.  
It would be great `julia` would do it automatically knowing these vectors and arrays dynamically without degrading performance.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [December 17, 2020, 8:04pm UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/7 "2020-12-17T20:04:14Z")

</div>

> [@vedasulo](#):
>
> `array to vector`

`Vector` is just an alias for unidimensional `Array`, i.e., `Vector`s are `Array` objects (`Array{T, 1}` more specifically). I am worried that maybe you did not understand my explanation.

---

<div class="post-metadata">

**Author:** ![vedasulo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vedasulo/32/20324_2.png) [@vedasulo](https://discourse.julialang.org/u/vedasulo)\
**Post date:** [December 18, 2020, 4:00am UTC](https://discourse.julialang.org/t/is-there-way-to-know-methods-functions-of-classes-modules-functions/51944/8 "2020-12-18T04:00:22Z")

</div>

Hi I’ve understand it, nothing to worry 🙂 I may be able to understand after some uses.  
I had thought we could use datatypes dynamically but little bit disappointed by these , but although this is ok, i may be ok .
