ChatGPT <https://chat.openai.com/chat> appears to ...
# linking-together
w
ChatGPT https://chat.openai.com/chat appears to be open general use. In this thread https://twitter.com/tylerangert/status/1598389755997290507 someone gets ChatGPT to "redesign git step by step." I thought it would be fun to ask about how Procs in Ruby work. I'll say more as a comment. tl;dr ChatGPT gets them confused with blocks, which any person might do who has read about Ruby but hasn't programmed in it.
In my ChatGPT conversation, I it to make a list of ways to invoke Procs in Ruby. One item on the list was
yield(10, &my_proc)
, which really doesn't work at all. So I said, "&my_proc allows you to pass my_proc as the block to a method, but yield(10, &my_proc) won't usually call my_proc. Can you define a method called silly_yield so that silly_yield(10, &my_proc) does do what think yield is doing?” Here's the reply.
Though the list didn't include all the other ways you can invoke a Proc, it did think of one that didn't immediately come to mind,
my_proc === 10
. I asked vaguely why
===
is defined on Proc, how would you use it? And eventually wrapped up with an example before, it seems, ChatGPT decided I had used too much of its CPU.
My next message would have been, "That's a nice example. Did you know you can write
proc(&:odd?)
instead? Let's see the example using that shorter syntax instead."