# If else question

**URL:** <https://forums.kodeco.com/t/if-else-question/136231>\
**Category:** Swift\
**Created:** [March 27, 2021, 1:13am UTC](https://forums.kodeco.com/t/if-else-question/136231 "2021-03-27T01:13:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drleewood](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/drleewood/32/81494_2.png) [@drleewood](https://forums.kodeco.com/u/drleewood)\
**Post date:** [March 27, 2021, 1:13am UTC](https://forums.kodeco.com/t/if-else-question/136231/1 "2021-03-27T01:13:38Z")

</div>

Why do I get error:

"Cannot convert value of type ‘(Double) → some View’ to expected argument type ‘Double’ "

with this code in one of the tutorials:

```
@Environment(\.colorScheme) var colorScheme
     .
     .
           if colorScheme == .dark {
              let opacity = 0.1}
           else {
              let opacity = 0.3}

```

when i use above with:

```
              [Color("RingsColor").opacity(opacity)

```

but the tutorial code works

```
                 let opacity = colorScheme == .dark ? 0.1 : 0.3

```

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [September 9, 2021, 5:14pm UTC](https://forums.kodeco.com/t/if-else-question/136231/2 "2021-09-09T17:14:19Z")

</div>

Closed on September 9, 2021, 5:14pm UTC

This topic was automatically closed after 166 days. New replies are no longer allowed.
