These are chat archives for ramda/ramda

29th
Dec 2017
klequis
@klequis
Dec 29 2017 19:27

Hi all, I'm new to ramda and to functional programming ... I want to append an object to an array of objects: append { id: 3, name: 'third' } to [{ id: 1, name: 'first' }, { id: 2, name: 'second' }]

I tried merge but got back an object instead of an array?

Einar Norðfjörð
@nordfjord
Dec 29 2017 19:50
R.append
‘’’R.append(obj, arr)’’’
klequis
@klequis
Dec 29 2017 19:51
will give that a try - thanks
klequis
@klequis
Dec 29 2017 20:07

Turns out I actually have an object in Redux state that is being converted into an array. I really needed to merge an object into an object so I'm doing

var state = {
  "0": {
    id: 1,
    name: 'first',
  },
  "1": {
    id: 2,
    name: 'second',
  },
}
R.merge(state, { "3": { id: 3, name: 'third'}})

Is merge the correct function to use?