This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pry | |
module DefaultCommands | |
Cd = Pry::CommandSet.new do | |
create_command "cd" do | |
group "Context" | |
description "Move into a new context (object or scope)." | |
banner <<-BANNER | |
Usage: cd [OPTIONS] [--help] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# otherwise just pops a binding and stores it as old binding | |
_pry_.old_binding[:binding] = _pry_.binding_stack.pop | |
_pry_.old_binding[:append] = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% pry | |
[1] pry(main)> cd :foo | |
# Save 'main' as old_binding; append == false (the next call of `cd -` should not append old_binding to binding_stack) | |
[2] pry(:foo):1> cd - | |
# Pull out ':foo' and save it as old_binding; append == true (the next call of `cd -` should append old_binding to binding_stack) | |
[3] pry(main)> cd - | |
# All over again... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="iso-8859-1"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta name="generator" content= | |
"HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it 'should keep correct old stack' do | |
#1 | |
redirect_pry_io(InputTester.new("cd @", "cd -", @cs, "exit-all")) do | |
Pry.start(@o) | |
end | |
Pad.cs.old_stack.should == nil | |
#2 | |
redirect_pry_io(InputTester.new("cd :mon_dogg", "cd @", @cs, "exit-all")) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby | |
?===?=??===?=:?===?=??===?=:?===?=??===?=:?===?=.iloveyoufowl!? ?===?=:?===?=??===?=:?===?=??===?=:?===?= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (1) | |
# Meh. | |
num = 6969 | |
num.to_s.length #=> 4 | |
# (2) | |
# Hm... | |
num = 6969 | |
len = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( ͡° ͜ʖ ͡°) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval "100 + 1\n (42 + 100)" #=> 142 | |
eval "100 + 1\n + (42 + 100)" #=> 142 | |
# But... | |
eval "100 +\n (42 + 100)" #=> 242 | |
eval "100 +\n + (42 + 100)" #=> 242 | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [].each do |elem| | |
puts "NOT EMPTY!" | |
end.empty? | |
puts "EMPTY!" | |
end | |
#EMPTY! | |
#=> nil | |
if [:piglet].each do |elem| | |
puts "NOT EMPTY!" |