Skip to content

Commit

Permalink
Merge #14
Browse files Browse the repository at this point in the history
14: Loop in a more rubyish way in Readme r=Hywan a=denniscollective

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.

Co-authored-by: Dennis Collinson <dennis.collective@gmail.com>
  • Loading branch information
bors[bot] and dnsco committed Jun 21, 2019
2 parents c7aba0a + ca86a69 commit 9b35e9c
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 9b35e9c

Please sign in to comment.