Day #43

Rethrows

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/, republished 09/16/2022.

Licensed under CC BY-NC-SA 4.0
Last updated on Sep 28, 2021 00:00 UTC
Built with Hugo
Theme Stack designed by Jimmy