Skip to content

Commit

Permalink
Merge pull request swirldev#246 from alex-dranoel/print-in-skip
Browse files Browse the repository at this point in the history
Add print statement in skip() to output the command return value
  • Loading branch information
WilCrofter committed Jan 13, 2015
2 parents 22ba715 + b93075e commit 9506605
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/swirl.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,23 @@ resume.default <- function(e, ...){
}
e$expr <- parse(text=correctAns)[[1]]
ce <- cleanEnv(e$snapshot)
e$val <- suppressMessages(suppressWarnings(eval(e$expr, ce)))
# evaluate e$expr keeping value and visibility information
# store the result in temporary object evaluation in order
# to avoid double potentially time consuming eval call
evaluation <- withVisible(eval(e$expr, ce))
e$vis <- evaluation$visible
e$val <- suppressMessages(suppressWarnings(evaluation$value))
xfer(ce, globalenv())
ce <- as.list(ce)

# Inform the user and expose the correct answer
swirl_out("Entering the following correct answer for you...",
skip_after=TRUE)
message("> ", e$current.row[, "CorrectAnswer"])


if(e$vis & !is.null(e$val)) {
print(e$val)
}
}

# Make sure playing flag is off since user skipped
Expand Down

0 comments on commit 9506605

Please sign in to comment.