4 ms·
As a very mediocre ruby programmer, is there an equivalent in ruby to this? If you have a little pattern that is more clever than 'puts' everywhere, please shar
by digitalsushi 8y ago
As a very mediocre ruby programmer, is there an equivalent in ruby to this? If you have a little pattern that is more clever than 'puts' everywhere, please share, it would be well received by at least one person out there. Thanks!
- johnernaut 8y agoYes, check out Pry: https://pryrepl.org/ https://pryrepl.org/
- alexisnorman 8y agoSecond that, pry rules!
- petercooper 8y agoSomething that prints out the state after running each line of code? No, I don't think so, but I believe it wouldn't be too hard to rig up something similar with TracePoint - https://ruby-doc.org/core-2.2.0/TracePoint.html https://ruby-doc.org/core-2.2.0/TracePoint.html - which is a built in Ruby way to trace code execution. For example, dump this into a file and run it: TracePoint.trace(:line) do |tp| STDERR.puts "Ran: #{File.readlines(tp.path)[tp.lineno - 1]}" end a = 10 b = 5 puts a a += b puts a puts b It'll print out each line of code as it runs it. You could then parse each line for identifiers and print them out, etc. It'd be a project, but it's doable.
- raldu 8y agoCheck out byebug: https://github.com/deivid-rodriguez/byebug https://github.com/deivid-rodriguez/byebug