From 9393f239f6426c8772bf7bd739df7b23f79f9f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Fri, 27 May 2022 13:22:37 +0200 Subject: [PATCH] add example of mutating values in function --- ch02.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ch02.jl b/ch02.jl index f04b07a..5b14dd4 100644 --- a/ch02.jl +++ b/ch02.jl @@ -218,6 +218,14 @@ end s s / length(y) +function f!(x) + x[1] = 10 + return x +end +x = [1, 2, 3] +f!(x) +x + # Code for listing 2.7 function times_two(x)