These are chat archives for ramda/ramda

28th
Sep 2018
Cristian Velasquez Ramos
@cevr
Sep 28 2018 00:56
@m59peacemaker Sorry for the late reply, but thank you very much! That's great!
Johnny Hauser
@m59peacemaker
Sep 28 2018 04:36
@cevr Glad to help!
Sergei
@osenvosem
Sep 28 2018 09:50
Hello, guys. Newbie question: let's assume I have an array of objects and I need to update a property in an object inside the array. How can I do that with Ramda?
Joe Egan
@joeegan
Sep 28 2018 10:41

@osenvosem One possible way of achieving this is assocPath

const arr = [{ a: 1, b: 2}, {a: 1, b: 2}, {a: 1, b: 2}];
assocPath([1, 'b'], 3)(arr)

It'll return you a new copy of the array mind.

Sergei
@osenvosem
Sep 28 2018 12:21
@joeegan thank you.
Ok, what if there is an array in each object and I need to add a new element to that array and return the top level array?
Joe Egan
@joeegan
Sep 28 2018 12:29
@osenvosem
const arr = [{ a: 1, b: [1, 2, 3] }, {a: 1, b: [1, 2, 3] }, {a: 1, b: [1, 2, 3] }];
const myLens = lensPath([1, 'b']);
over(myLens, append(4), arr);
// [{"a": 1, "b": [1, 2, 3]}, {"a": 1, "b": [1, 2, 3, 4]}, {"a": 1, "b": [1, 2, 3]}]
Jason Gretz
@jagretz
Sep 28 2018 14:44
d
Sergei
@osenvosem
Sep 28 2018 15:24
@joeegan thank you again ))