Skip to content

Commit acb2d7e

Browse files
committed
Update patch documentation on README
The patches suggested in the README only work when you have string keys on the hash.
1 parent 7271736 commit acb2d7e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ diff.should == [['-', 'a[0].x', 2], ['-', 'a[0].z', 4], ['-', 'a[1].y', 22], ['-
7272
patch example:
7373

7474
```ruby
75-
a = {a: 3}
76-
b = {a: {a1: 1, a2: 2}}
75+
a = {'a' => 3}
76+
b = {'a' => {'a1' => 1, 'a2' => 2}}
7777

7878
diff = HashDiff.diff(a, b)
7979
HashDiff.patch!(a, diff).should == b
@@ -82,8 +82,8 @@ HashDiff.patch!(a, diff).should == b
8282
unpatch example:
8383

8484
```ruby
85-
a = [{a: 1, b: 2, c: 3, d: 4, e: 5}, {x: 5, y: 6, z: 3}, 1]
86-
b = [1, {a: 1, b: 2, c: 3, e: 5}]
85+
a = [{'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5}, {'x' => 5, 'y' => 6, 'z' => 3}, 1]
86+
b = [1, {'a' => 1, 'b' => 2, 'c' => 3, 'e' => 5}]
8787

8888
diff = HashDiff.diff(a, b) # diff two array is OK
8989
HashDiff.unpatch!(b, diff).should == a

0 commit comments

Comments
 (0)