tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
3
Task/Copy-a-string/Groovy/copy-a-string-1.groovy
Normal file
3
Task/Copy-a-string/Groovy/copy-a-string-1.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def string = 'Scooby-doo-bee-doo' // assigns string object to a variable reference
|
||||
def stringRef = string // assigns another variable reference to the same object
|
||||
def stringCopy = new String(string) // copies string value into a new object, and assigns to a third variable reference
|
||||
4
Task/Copy-a-string/Groovy/copy-a-string-2.groovy
Normal file
4
Task/Copy-a-string/Groovy/copy-a-string-2.groovy
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
assert string == stringRef // they have equal values (like Java equals(), not like Java ==)
|
||||
assert string.is(stringRef) // they are references to the same objext (like Java ==)
|
||||
assert string == stringCopy // they have equal values
|
||||
assert ! string.is(stringCopy) // they are references to different objects (like Java !=)
|
||||
Loading…
Add table
Add a link
Reference in a new issue