# How to create a function in Julia that can accept an array or a scalar as input argument?

**URL:** <https://discourse.julialang.org/t/how-to-create-a-function-in-julia-that-can-accept-an-array-or-a-scalar-as-input-argument/36394>\
**Category:** New to Julia\
**Created:** [March 23, 2020, 3:08pm UTC](https://discourse.julialang.org/t/how-to-create-a-function-in-julia-that-can-accept-an-array-or-a-scalar-as-input-argument/36394 "2020-03-23T15:08:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 23, 2020, 3:32pm UTC](https://discourse.julialang.org/t/how-to-create-a-function-in-julia-that-can-accept-an-array-or-a-scalar-as-input-argument/36394/2 "2020-03-23T15:32:42Z")

</div>

> [@josimar](#):
>
> Hi, when creating new functions in Julia, do I need to specify the input type of the arguments ? Is this required for speed or only for organization ?

No, this is not required.  
There is a recent thread

> [@Multiplication times for complex matrices: julia vs Matlab](https://discourse.julialang.org/t/multiplication-times-for-complex-matrices-julia-vs-matlab/36163/):
>
> I’ve been looking at some different filter approaches for analyzing ECG signals using Matlab and have recently implemented them in julia in order to get a speed improvement. I have not been seeing the expected improvements and have tracked the issue down to the time for multiplying complex matrices. I have made some simple examples in both cases to evaluate the times. The julia example is rough as I am new to julia. #!/usr/local/bin/julia module TmMlt ENV["CMPLXROOT"] = "/home/martin/Dropbox/…

where there was a nice explanation about this by @bcmichael

---

_[View the full topic](https://discourse.julialang.org/t/how-to-create-a-function-in-julia-that-can-accept-an-array-or-a-scalar-as-input-argument/36394)._
