crystal-community / icr

Interactive console for Crystal programming language
MIT License
505 stars 40 forks source link

Last result local '__' #63

Closed veelenga closed 7 years ago

veelenga commented 7 years ago

Inspired by https://github.com/pry/pry/wiki/Special-Locals#Last_result

icr(0.23.1) > a = 42
 => 42
icr(0.23.1) > __
 => 42
icr(0.23.1) > __ + 1
 => 43
icr(0.23.1) > 1 + __
 => 44
icr(0.23.1) > __.to_s
 => "44"
icr(0.23.1) > __.to_i
 => 44
icr(0.23.1) > inc = -> { __ + 1 }
 => #<Proc(Int32):0x1002ea350>
icr(0.23.1) > inc.call
 => 45
...

cc @jwoertink

jwoertink commented 7 years ago

Beautiful! I think it looks nice, and doesn’t feel awkward. Plus the change is pretty minimal. :+1:

veelenga commented 7 years ago

@greyblake @crystal-community WDYT?

veelenga commented 7 years ago

Hey guys. Can I merge this?

greyblake commented 7 years ago

I think yes. Would someone mind adding a description of this feature to README?

veelenga commented 7 years ago

@greyblake thanks. Added in #64