R/scalaLast.R

Defines functions scalaLastEngine scalaLast

Documented in scalaLast

#' Retrieve the Last Scala Computation
#'
#' This function retrieves the last result from the supplied Scala bridge.
#'
#' @param bridge A Scala bridge
#'
#' @export
#' @seealso \code{\link{scalaFindBridge}}
#' 
#' @examples \donttest{
#' s <- scala()
#' s * "2+3"
#' scalaLast(s)
#' close(s)
#' }
#' 
scalaLast <- function(bridge=scalaFindBridge()) {
  details <- attr(bridge,"details")
  last <- scalaLastEngine(details)
  if ( details[["interrupted"]] ) invisible() else last
}

scalaLastEngine <- function(details) {
  checkConnection(details)
  if ( details[["interrupted"]] ) {
    cat("<< waiting for previously interrupted computation to finish >>\n")
    assign("interrupted",FALSE,envir=details)
    pop(details)
  }
  details[["last"]]
}

Try the rscala package in your browser

Any scripts or data that you put into this service are public.

rscala documentation built on Aug. 15, 2023, 9:07 a.m.