summaryrefslogtreecommitdiffhomepage
path: root/julia.html.markdown
diff options
context:
space:
mode:
authorBoris Verkhovskiy <boris.verk@gmail.com>2024-04-03 02:30:27 -0700
committerGitHub <noreply@github.com>2024-04-03 02:30:27 -0700
commit6d87022050ffbd5d818781427329c5362e3df197 (patch)
tree3809b2b1a7790d8b30e6d694c575eb68f02f661c /julia.html.markdown
parentc76b8f690a577d9ff89947d79c36a96a7c3b4deb (diff)
parente8dabf3c1955e1a458e8bc936587ad59772a9c33 (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'julia.html.markdown')
-rw-r--r--julia.html.markdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/julia.html.markdown b/julia.html.markdown
index 4d8eb497..336cd2b8 100644
--- a/julia.html.markdown
+++ b/julia.html.markdown
@@ -356,6 +356,20 @@ intersect(filledSet, otherSet) # => Set([4, 3, 5])
union(filledSet, otherSet) # => Set([4, 2, 3, 5, 6, 1])
setdiff(Set([1,2,3,4]), Set([2,3,5])) # => Set([4, 1])
+# Assignment with `=` attaches a new label to the same value without copying
+a = [1, 2, 3]
+b = a
+# Now `b` and `a` point to the same value, so changing one affects the other:
+a[3] = 5
+b[3] # => 5
+
+# The `copy()` function can create a shallow copy of an array, dictionary,
+# or other container
+a = [1, 2, 3]
+c = copy(a)
+a[3] = 5
+c[3] # => 3
+
####################################################
## 3. Control Flow
####################################################