• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

3 lines i dont understand

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my task is..:
1) create a dictionary. the user should feed words to both languages till the word "enough" is typed in.
2) write a sentence in hebrew.
3)seperate teh words in teh senentece and compare them to the words in teh dictionary i previously created

i practiced rewriting the code myself, i re-wrote everything successfully . apart from those lines.. i dont know what they mean,,please help.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, when you were "playing computer" with the pen and paper, what did you come up with?

Maybe start by breaking down each of the conditionals: what do each of the following mean?

1) index < sentence.length()
2) sentence.charAt(index) == ''
3) sentence.charAt(index) != ''

As to whether or not it works with only one of those, when you commented one out, what happened?

(And I'm not sure what "practiced rewriting the code myself" means; if you re-wrote it yourself, why would you write two lines you didn't understand, and how did you know to write them?)
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code:is essentially identical, and should be refactored into a single method.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic