2021年3月12日星期五

Condition handlers in R

I have been reading Hadley Wickham's Advanced R for a couple of weeks and I have reached the conditions section. In one of the exercises I came across this question and I could not figure out the explanation. I would be grateful if you could explain it to me a little bit:

Q. Explain the results of running this code:

withCallingHandlers(   message = function(cnd) message("b"),   withCallingHandlers(    message = function(cnd) message("a"),    message("c")  )  )  #> b  #> a  #> b  #> c  

I just don't understand what are default and parent handlers and why running message(c) first triggers the message(b) than message(a). An explanation is much appreciated.

https://stackoverflow.com/questions/66607569/condition-handlers-in-r March 13, 2021 at 05:41AM

没有评论:

发表评论