• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic