merge: Merge all Members of Two Instances

Description Usage Arguments Value Examples

Description

All public and private members of instance 2 will be copied to instance 1, overwriting any of the same names.

Usage

1
merge(inst1, inst2)

Arguments

inst1

instance to move members to

inst2

instance to move members from

Value

Q7 instance, with environment identity of inst1 and members from both instances.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Screamer <- type(function(words){
  scream <- function(){
    paste0(paste(words,
                 collapse = " "),
           "!!!")
  }
})

Whisperer <- type(function(words){
  whisper <- function(){
    paste0("shhhhhhh.....",
           paste(words,
                 collapse = " "),
           "...")
  }
})

p1 <- Screamer("I love you")
p1$scream()

p2 <- Whisperer("My parents came back")
p2$whisper()

p1 <- p1 %>% merge(p2)

# note the the "word" for both methods became that of p2
p1$whisper()
p1$scream()

Q7 documentation built on Jan. 13, 2021, 10:11 a.m.