[ create a new paste ] login | about

Link: http://codepad.org/KoDFLu0F    [ raw code | output | fork | 1 comment ]

joshua_cheek - Ruby, pasted on Oct 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
$stdin = DATA

print "Enter your first name: "
fname = gets.chomp

print "Enter your last name: "
lname = gets.chomp

puts "\nHello #{fname} #{lname}"

__END__
Josh
Cheek


Output:
1
2
Enter your first name: Enter your last name: 
Hello Josh Cheek


Create a new paste based on this one


Comments:
posted by joshua_cheek on Nov 15
Shows how you can set $stdin to be DATA, which then allows you to pull input from after __END__ which can be useful for testing or demonstrating your app.
reply