DAY #43

Rethows is a keyword to indicate that a function is wrapping around a throwing function.

1
2
3
4
func iThrow() throws -> Bool {}
func iDontThrow() -> Bool {}

func iWrap(t: (Void) -> throws Bool) rethrows {}

iWrap can wrap either of the functions. During compilation, Swift can tell if the wrapped function throws or not - which means it will not ask you to implement try/catch for a iDontThrow() parameter.

Originally published 09/28/2021 @ https://pittcsc.org/ Discord

Published here on 09/16/2022. Blog published date reflects the original date of publication.