Skip to content

Commit

Permalink
Loop in a more rubyish way in Readme
Browse files Browse the repository at this point in the history
Ruby devs generally iterate using the more functional methods rather than setting up an index and mutating it.
If this they are the target audience of this doc this would probably be clearer.
  • Loading branch information
dnsco committed Jun 12, 2019
1 parent baa8363 commit ca86a69
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,12 @@ pointer = instance.exports.return_string
memory = instance.memory.uint8_view pointer

# Read the string pointed by the pointer.
nth = 0
string = ""

while true
char = memory[nth]

if 0 == char
break
end
string = ""

memory.each do |char|
break if char == 0
string += char.chr
nth += 1
end

puts string # Hello, World!
Expand Down

0 comments on commit ca86a69

Please sign in to comment.