Mercurial > repos > other > SevenLanguagesInSevenWeeks
annotate 1-Ruby/object-all-things-2.rb @ 93:39084e2b8744
Add a function for word-aware text wrapping
Potentially hugely inefficient because we iterate through the
string character by character, but then splitting it first and
iterating over words still needs to iterate over the string to
know where to split.
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 18 Jun 2019 21:05:00 +0100 |
parents | 8d46064c9afc |
children |
rev | line source |
---|---|
6
a50d2fac49ce
Add some experiments of what different objects are and what functions they have
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 #! /usr/bin/env ruby |
a50d2fac49ce
Add some experiments of what different objects are and what functions they have
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 |
7
b8f4577db289
Add "false" and "true" to our OBJECT ALL THINGS list
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
3 objects = [ 4, 3.14, 'Pi', 'π', false, true ] |
16
8d46064c9afc
Be a nice Ruby user and follow block convention for do/end vs {}
IBBoard <dev@ibboard.co.uk>
parents:
7
diff
changeset
|
4 objects.each do |obj| |
6
a50d2fac49ce
Add some experiments of what different objects are and what functions they have
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 puts "#{obj} (#{obj.class})" |
a50d2fac49ce
Add some experiments of what different objects are and what functions they have
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 obj.methods.each { |method| puts " #{method}" } |
16
8d46064c9afc
Be a nice Ruby user and follow block convention for do/end vs {}
IBBoard <dev@ibboard.co.uk>
parents:
7
diff
changeset
|
7 end |