New example showing use of %catchs and %
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8355 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3b44cfaff8
commit
650ea1c873
4 changed files with 160 additions and 0 deletions
45
Examples/ruby/exception_class/runme.rb
Normal file
45
Examples/ruby/exception_class/runme.rb
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
require 'example'
|
||||
|
||||
q = Example::IntQueue.new(10)
|
||||
|
||||
puts "Inserting items into intQueue"
|
||||
|
||||
begin
|
||||
0.upto(100) do |i|
|
||||
q.enqueue(i)
|
||||
end
|
||||
rescue Example::FullError => e
|
||||
puts "Maxsize is: #{e.maxsize}"
|
||||
end
|
||||
|
||||
puts "Removing items"
|
||||
|
||||
begin
|
||||
loop do
|
||||
q.dequeue()
|
||||
end
|
||||
rescue Example::EmptyError => e
|
||||
## do nothing
|
||||
end
|
||||
|
||||
q = Example::DoubleQueue.new(1000)
|
||||
|
||||
puts "Inserting items into doubleQueue"
|
||||
|
||||
begin
|
||||
0.upto(100) do |i|
|
||||
q.enqueue(i*1.5)
|
||||
end
|
||||
rescue Example::FullError => e
|
||||
puts "Maxsize is: #{e.maxsize}"
|
||||
end
|
||||
|
||||
puts "Removing items"
|
||||
|
||||
begin
|
||||
loop do
|
||||
q.dequeue()
|
||||
end
|
||||
rescue Example::EmptyError => e
|
||||
# do nothing
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue