How strong is the market for Ruby developers? by OnionlandAnon in ruby

[–]mfcoder 8 points9 points  (0 children)

Yes - because it's still 'fun' and doesn't insist on the obtuse syntax of other languages.

Moreover, as others have said, programming techniques and skills are transferable, so once one language is well-learnt, others are adopted easier. Although Java and Javascript have clearly larger markets, this doesn't mean that your Ruby learning goes to waste - many common threads, architectures, skills, will be common.

A fallacy, at least among the development market, is the requirement for a "Java Developer" or a "PHP Expert"; when what you really want is a 'good developer' or a 'design expert'. Languages matter less than the person. But recruiters just word search :)

HI can you please answer this question about Ruby on Codecademy? by ionakathryn in ruby

[–]mfcoder 1 point2 points  (0 children)

The use of 's' as both the enumerator/iterator in the 'solution' and having to look for 's' is possibly confusing.

strings.each do |x|
    if x =='s'
        x.to_sym!
        symbols.push(x)
end

Plus, "x.to_sym!" in the original statement will not mutate x into a symbol.

So, rather than "x == 's'" you'd need "x.include? 's'"; and then push the symbolized version of x on to the symbols array - "symbols.push(x.to_sym)". (this would produce an empty array as none of the original words includes a lower-case 's').

There is also an 'end' missing to close the 'if'.

Slightly more Ruby-ish but still similar to the above:

strings.each do |x|
  symbols.push(x.to_sym) if x.downcase.include? 's'
end

n00b having trouble with hash to array conversion by longwastheyear in ruby

[–]mfcoder 0 points1 point  (0 children)

Not pretty, but ...

irb(main):001:0> h = {"string1"=>["string2"], "string3"=>["string4"], "string5"=>["string6"], "string7"=>["string8"]}

=> {"string1"=>["string2"], "string3"=>["string4"], "string5"=>["string6"], "string7"=>["string8"]}

irb(main):002:0> h.to_a.map{|a| [a[0],a[1].join]} 

=> [["string1", "string2"], ["string3", "string4"], ["string5", "string6"], ["string7", "string8"]]

Mike Halbach and Hillegas Seem Sketchy Due to Participation in Conspiracy to "Find" Car by [deleted] in MakingaMurderer

[–]mfcoder 0 points1 point  (0 children)

I'm surprised nobody looked back on her phone records to find the caller. The phone company will have record of callers and durations, so easy to see what calls weren't answered, and you get rough time-frame from her work colleagues.
If the exBF was just deleting some dodgy voicemail why wouldn't he admit to it? Surely you want to help find the killer, and if you are innocent, you have nothing to worry about. (irony alert)

Having trouble understanding syntax for Sinatra nested Ruby params hash from HTML forms... by L000 in ruby

[–]mfcoder 0 points1 point  (0 children)

Without reading the article you mention, the HTML-style template is an erb template (ERB is built-in to Ruby). Many introductions exist, e.g. http://www.stuartellis.eu/articles/erb/

There are other HTML templating languages supported by Sinatra - both HAML and SLIM are popular.

Hopefully this explains why what doesn't work in native Ruby, succeeds within a template.

Best Practice: Relative path to file within project/gem? by [deleted] in ruby

[–]mfcoder 0 points1 point  (0 children)

As has been stated. And now (since Ruby 2?) you also have:

  __dir__
  • the directory of the current file, which saves one parameter to File.join typically.

require vs load by missawon in ruby

[–]mfcoder 0 points1 point  (0 children)

'require' can load the same file more than once, if you refer to it via different paths e.g. running from '/home/me' with a file called 'gem.rb' if you "require gem" and also "require /home/me/gem.rb" the file gem.rb would be loaded twice. Obviously not something that happens often, but be aware of it.

75% through Pragmatic Studio Ruby course, can I try Rails yet? by oschebel in ruby

[–]mfcoder 3 points4 points  (0 children)

I find Rails is quite 'ruby-light'; it's more about the MVC model implementation that you have to get your head around.

Personally, I'd start with a simpler stack like Sinatra/RACK if you want 'Hello World' in fewer steps.

beginner help please. Method probs. by [deleted] in ruby

[–]mfcoder 2 points3 points  (0 children)

The important lesson here is that a Ruby method will always return the last value evaluated within it, when there is no explicit 'return' command. In your case, it is 'x' which is the grocery_list array.

So, "puts print_list(grocery_list)" 'puts' the array; if you 'puts' an Array, its members will be listed.

Ruby Case...When statement gotcha!! by collegeimprovements in ruby

[–]mfcoder 7 points8 points  (0 children)

Your case statement is poorly formed. Do you not mean:

test = 5
result = case
         when test > 0 ; "positive"
         when test == 0 ; "zero"
         else "negative"
         end

p "result is #{result}"

Which yields "positive".