File tree Expand file tree Collapse file tree
1_The_different_types_of_numbers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # e.g.:
2+ fixnum = 5
3+ bignum = 100_000_000_000_000_000_000
4+ rational = Rational ( 2 , 7 )
5+ complex = Complex ( 0.1 , 2.5 )
Original file line number Diff line number Diff line change 1+ require 'rspec'
2+
3+ describe "Your code" do
4+ [ [ 'solution::code' ] ]
5+
6+ {
7+ 'fixnum' => Fixnum ,
8+ 'bignum' => Bignum ,
9+ 'rational' => Rational ,
10+ 'complex' => Complex
11+ } . each do |variable , class_name |
12+ it "defines a variable with name \" #{ variable } \" " do
13+ expect ( !!defined? ( send ( variable ) ) ) . to be true
14+ end
15+
16+ if defined? ( send ( variable ) )
17+ it "defines a variable \" #{ variable } \" which is a #{ class_name } " do
18+ expect ( eval ( variable ) . class ) . to eq class_name
19+ end
20+ end
21+ end
22+ end
Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ Read more about Complex here: (ruby-doc core: Complex).
7676
7777---
7878
79- Create some numbers of the different described types in the interactive Ruby console
80- (` irb ` ) and press * v* to mark this unit green if you are done!
79+ Create a number of each described type and store it into a variable with the
80+ lowercased name of the number's class (e.g. * rational* for Rational).
81+ Create both types of Integers (* Fixnum* and * Bignum* )!
8182
8283---
You can’t perform that action at this time.
0 commit comments