# Broadcasting and the function keyword arguments

**URL:** https://discourse.julialang.org/t/broadcasting-and-the-function-keyword-arguments/71629
**Category:** General Usage
**Tags:** broadcast
**Created:** [November 17, 2021, 3:36am UTC](https://discourse.julialang.org/t/broadcasting-and-the-function-keyword-arguments/71629 "2021-11-17T03:36:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Oko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oko/32/22734_2.png) [@Oko](https://discourse.julialang.org/u/Oko)
#### Post date: [November 17, 2021, 3:36am UTC](https://discourse.julialang.org/t/broadcasting-and-the-function-keyword-arguments/71629/1 "2021-11-17T03:36:54Z")

</div>

In the lieu of the fact that [the broadcast is faster than the dot syntax](https://discourse.julialang.org/t/why-is-broadcast-faster-than-the-dot-syntax-performance-differences-between-broadcast-and-broadcast/53814)

I would like to replace the following code snippet

```julia
#!/usr/bin/julia
using Graphs

n = 10
p = 0.1:0.01:0.5

erdos_renyi.(n,p;is_directed=true, seed=-1)

```

which correctly generates 11 directed E-R-Gilbert graphs with the `broadcast` function.

This works

```julia
broadcast(erdos_renyi,n,p)

```

but defaults to the undirected graphs. How do I use keyword arguments with the `broadcast` function?

Edit:

Somebody already asked this question on the [stackoverflow](https://stackoverflow.com/questions/48738016/julia-broadcasting-functions-with-keyword-arguments). I took a clue from one of the accepted answer and got what I wanted.

```julia
broadcast((x,y) -> erdos_renyi(x,y;is_directed=true, seed=-1),n,p)

```

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [November 17, 2021, 5:46am UTC](https://discourse.julialang.org/t/broadcasting-and-the-function-keyword-arguments/71629/2 "2021-11-17T05:46:59Z")

</div>

Can you mark it as “solved”?

(FYI, the thread you’ve linked does not really show that `broadcast` is faster.)

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [November 17, 2021, 6:13am UTC](https://discourse.julialang.org/t/broadcasting-and-the-function-keyword-arguments/71629/3 "2021-11-17T06:13:52Z")

</div>

> [@Oko](#):
>
> In the lieu of the fact that [the broadcast is faster than the dot syntax](https://discourse.julialang.org/t/why-is-broadcast-faster-than-the-dot-syntax-performance-differences-between-broadcast-and-broadcast/53814)

No, it isn’t, and that thread shows they are the same. It’s a benchmarking issue. Just use dot.
