2

What are the differences between writing try before variable or after it assignment sign? I mean this:

do {
    audioPlayer = try AVAudioPlayer(contentsOf: soundUrl!)
} catch {
    print(error)
}

and this:

do {
    try audioPlayer = AVAudioPlayer(contentsOf: soundUrl!)
}
catch {
    print(error)
}

Both of them work I'm just curious.

Witek Bobrowski
  • 3,749
  • 1
  • 20
  • 34
dziobaczy
  • 891
  • 9
  • 17

0 Answers0