Sie sind auf Seite 1von 3

Questions for Debugging Exercise

- Inquiry for: numbers.inject(:+)


==> numbers. inject(:+) : means that each of the number in the
array will be summed together, but, the problem could be with
numbers > need to change it to something like (5,3,6,10) if its
executable.
> ref:
http://stackoverflow.com/questions/710501/need-a-simple-
explanation-of-the-inject-method
http://blog.jayfields.com/2008/03/ruby-inject.html
**(for P1 debug) http://apidock.com/ruby/Enumerable/inject
> about .inject()
> typically used for summation > have an array of numbers
and want the summation of the numbers
> so, if x = [1,2,3], then .inject will give the result of 1+2+3 = 6
> but, still need to know the proper syntax. ex:

[1,2,3,4].inject(0) {|result, element| result+element}

> from this example, (0) means the starting number/initial


number. If you change it to (1), then youll get 11 as the new answer
> so, I guess, without the very long syntax after (0), .inject
wont be properly executed?

- Good refs on method:


http://www.skorks.com/2009/08/method-arguments-in-ruby/

- TypeError
- related: Type System
> a collection of rules || that assign a property called type || to
various constructs
> purpose of type system: reduce bugs

[Day 2 Challenge]
- list of enumerable methods
- good reading:
http://www.eriktrautman.com/posts/ruby-explained-map-select-and-other-
enumerable-methods
http://ruby-doc.org/core-2.3.1/Enumerable.html#method-i-map

- doend functions the same as { | | }

- challenge: generating random number using self-developed shuffle method


> http://excode.io/code/19/fisher-yates-shuffle/ruby
> https://www.safaribooksonline.com/library/view/ruby-
cookbook/0596523696/ch04s10.html

- Challenge: regular expression challenge


>
> regex: question with 3 ssns
> ref: http://stackoverflow.com/questions/7993662/whats-the-
difference-between-scan-and-match-on-ruby-string

> regex: question on obfuscate


> ref: http://apidock.com/ruby/String/scan
> ref: http://stackoverflow.com/questions/20362267/obfuscating-
numbers-in-a-string
> ref: https://www.blueboxcloud.com/insight/blog-article/using-
regular-expressions-in-ruby-part-2-of-3

- regex syntax_nhkz self learn


> __.scan( /insert regex expression/ )
write everything in the bracket. Prolly what you want to
know now is how to make it recognize groups of words etc.

> .sub v .sub! , .sub v .gsub


- ref: http://www.dotnetperls.com/sub-ruby
- http://ruby-doc.org/core-1.9.3/String.html#method-i-gsub
- http://stackoverflow.com/questions/6766878/what-is-the-difference-
between-gsub-and-sub-methods-for-ruby-strings

> can support with understanding Rubular


- http://www.tutorialspoint.com/ruby/ruby_regular_expressions.htm

> specific reference to the SSN challenge& helped solve code


- http://stackoverflow.com/questions/20386228/formatting-a-social-
security-number-using-a-regex
- http://codepad.org/I1gUeeE0

> other specific reference to SSN


- http://stackoverflow.com/questions/23484056/in-ruby-how-can-i-
check-for-social-security-number-that-doesnt-start-with-9

> understanding Regex


- http://rubylearning.com/satishtalim/ruby_regular_expressions.html

> Pig Latin ref:


- http://ruby.about.com/od/beginningruby/fl/Ruby-Challenge-Pig-
Latin.htm

Das könnte Ihnen auch gefallen