What is the "on" keyword in ruby?
ruby
Solution
It's not a keyword, but a simple instance method called on the `Cinch::Bot` object you just created. The block you're passing to `Cinch::Bot.new` is evaluated against that new object (https://github.com/cinchrb/cinch/blob/master/lib/cinch/bot.rb#L363). It's a neat trick called a "DSL" (Domain-Specific Language): it looks like magic keywords or global methods, but it's really just methods called on a normal object.
Looks like `on` is defined in https://github.com/cinchrb/cinch/blob/master/lib/cinch/bot.rb#L188.
The code could instead be written like this:
bot = Cinch::Bot.new
bot.on :channel do |m|
...
end
Problem
I'm a student learning ruby and I wasn't sure what "on" does in this code. https://github.com/cinchrb/cinch/blob/master/examples/basic/seen.rb For example, ``` on :channel do |m| @users[m.user.nick] = Seen.new(m.user.nick, m.channel, m.message, Time.new) end ``` Can someone explain?