Forumchem - Forum with AI(ALICE BOT & HAL9000) and TTS

More dificult for us, more easy for you
It is currently Fri Apr 19, 2024 7:35 am

All times are UTC





Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 
Author Message
 Post subject: Why would we need a return statement in this code? (Ruby)?
PostPosted: Mon Mar 29, 2021 5:55 pm 
Offline
User avatar

Joined: Thu Oct 15, 2009 2:55 pm
Posts: 10
def reverse(string)
reversed_string = ""

i = 0
while i < string.length
reversed_string = string[i] + reversed_string

i += 1
end

return reversed_string
end

# Testing the code below

puts(
reverse("abc") == "cba": + (reverse("abc") == "cba").to_s
)
puts(
reverse("a") == "a": + (reverse("a") == "a").to_s
)
puts(
reverse("") == "": + (reverse("") == "").to_s
)



Top
 Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


 
Search for:
 
Jump to:  

cron
Click me:
Powered by phpBB © 2000, 2002, 2005, 2007, 2008, 2009 phpBB Group
Chronicles phpBB3 theme by Jakob Persson. Stone textures by Patty Herford.
With special thanks to RuneVillage

This site have 4 type of tecnology in order to convert text to speech. By default you use the vozme tecnology. In order to know the other you need to sign for.


- Privacy Policy -