Project

General

Profile

Actions

Bug #14355

closed

clone issue

Added by Winklerbugs (Bart Winkler) over 6 years ago. Updated over 6 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:84858]

Description

#!/usr/bin/env ruby
aMutantSpeak = [[nil,nil],[nil,nil]]
aDogSpeak = aMutantSpeak.clone
aCatSpeak = aMutantSpeak.clone
aDogSpeak[0][0] = "W"
aCatSpeak[0][0] = "m"
aCatSpeak[0][1] = "e"
aDogSpeak[0][1] = "O"
aCatSpeak[1][0] = "o"
aDogSpeak[1][0] = "O"
aDogSpeak[1][1] = "F"
aCatSpeak[1][1] = "w"
print "aMutantSpeak ", aMutantSpeak
puts
print "aDogSpeak ", aDogSpeak
puts
print "aCatSpeak ", aCatSpeak

#all three arrays are now [["m","O"],["O","w"]]

This is what I wanted:

aMutantSpeak = [[nil,nil],[nil,nil]]

aDogSpeak = [["W","O"],["O","F"]]

aCatSpeak = [["m","e"],["o","w"]]

I think this is what clone should do.


Files

MutantSpeak.rb (402 Bytes) MutantSpeak.rb Winklerbugs (Bart Winkler), 01/14/2018 07:24 PM
Actions

Also available in: Atom PDF

Like0
Like0