Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1 +1,4 @@
This task is about copying a string. Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string.
{{omit from|bc}}
This task is about copying a string.
Where it is relevant, distinguish between copying the contents of a string
versus making an additional reference to an existing string.

View file

@ -1,4 +1,5 @@
---
category:
- String manipulation
- Simple
note: Basic language learning

View file

@ -0,0 +1,4 @@
"Hello, world\n" dup cp
str2ar dup 'Y' str2ar 0 paste ar2str
<<
<<

View file

@ -1,3 +1,2 @@
src = "this is a string"
<br><br>Note that all REXX values (variables) are stored as character strings.
dst = src

View file

@ -0,0 +1,9 @@
original = "hello"
reference = original # copies reference
copy1 = original.dup # instance of original.class
copy2 = String.new(original) # instance of String
original << " world!" # append
p reference #=> "hello world!"
p copy1 #=> "hello"
p copy2 #=> "hello"

View file

@ -0,0 +1,7 @@
original = "hello".freeze # prevents further modifications
copy1 = original.dup # copies contents (without status)
copy2 = original.clone # copies contents (with status)
p copy1.frozen? #=> false
p copy1 << " world!" #=> "hello world!"
p copy2.frozen? #=> true
p copy2 << " world!" #=> can't modify frozen String (RuntimeError)

View file

@ -1,4 +0,0 @@
original = "hello"
reference = original
copy1 = original.dup # instance of original.class
copy2 = String.new(original) # instance of String

View file

@ -0,0 +1,6 @@
let str1 = "original string"
let str2 = str1
let str1 = "new string"
echo "String 1:" str1
echo "String 2:" str2