In Swift, one can do something like:

```swift
guard let x = z else {return}  // z is "String?"

```

In this simple case, if `z` (an optional) is empty, the function will exit.

I really like this structure and recently started developing in Scala, and I was wondering if there's an equivalent in Scala.

What I found is this:

```scala
val x = if (z.isEmpty) return else z.get  // z is "Option[String]"

```

It works - but I still wonder if there's a more "Scala-ish" way of doing it.

**EDIT:** the use case is that a configuration argument is allowed to be `null` in the app, but this specific function has nothing to do in that case. I'm looking for the correct way to avoid calling code that will not work.