First of all, things like [] (array index) and []= are just methods in Ruby. x is an Array, and arrays have a []= method, which accepts two arguments, an index and a value to set.
Using send lets you pass an arbitrary “message” (method call) to object, with arbitrary parameters.
You could call x.send :sort, for example, to send the “sort” message to the array. Sort doesn’t need any parameters, though, so we don’t have to pass anything extra to it.
x#[]=, on the other hand, accepts two arguments. Its method can be thought of to look like this:
def []=(index, value)
self.set_value_at_index(index, value)
end
So, we can just invoke it with send :[]=, 0, 2, which is just like calling x[0] = 2. Neat, huh?