# Idiomatic Pluto flow control

**URL:** <https://discourse.julialang.org/t/idiomatic-pluto-flow-control/66418>\
**Category:** Pluto\
**Created:** [August 15, 2021, 4:32am UTC](https://discourse.julialang.org/t/idiomatic-pluto-flow-control/66418 "2021-08-15T04:32:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcgrigsby](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dcgrigsby/32/20746_2.png) [@dcgrigsby](https://discourse.julialang.org/u/dcgrigsby)\
**Post date:** [August 15, 2021, 4:32am UTC](https://discourse.julialang.org/t/idiomatic-pluto-flow-control/66418/1 "2021-08-15T04:32:22Z")

</div>

I’d like some advice on how to idiomatically use flow control with Pluto.

Here is a minimal example in pseudo code. Let’s say I want to do conditional evaluation. Here’s bare pseudo code of what I’m after that I’d use outside of Pluto:

```julia
if isfile(parquet_file_path)
  df = dataframe_from_parquet_file(parquet_file_path)
else
  df = dataframe_from_csv(csv_file_path)
end

```

This is contrived, and kind of stupid as presented, but is suitable for the questions I have.

I could take the above code and wrap it in a `begin` `end` block and use it in Pluto.

Alternatively, I could create a series Pluto cells, like this:

```julia
parquet_df = isfile(parquet_file_path) && dataframe_from_parquet_file(parquet_file_path) 

```

```julia
csv_df = dataframe_from_csv(csv_file_path)

```

```julia
df = parquet_df || csv_df 

```

In both cases, I’d end up with a `df` variable with the desired dataframe. The latter trades readability for strict compliance with having a single expression per cell. The former is nicer to read and, since it’s arguably not important for that code to be responsive, maybe it’s okay.

Since either work, there isn’t an absolute answer to this. Which (if either) is idiomatic? Is there a third, better choice?

Thanks!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 15, 2021, 2:27pm UTC](https://discourse.julialang.org/t/idiomatic-pluto-flow-control/66418/2 "2021-08-15T14:27:52Z")

</div>

The if statement is one expression, that’s different in Julia than in Python, for example. You can also write

```julia
df = if condition
   a
else
    b
end

```

The short form for this is the ternary operator

```julia
df = condition ? a : b

```
