Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can this C and PHP programmer learn Ruby and Rails?
    text
    copied!<p>I came from a C, php and bash background, it was easy to learn because they all have the same C structure, which I can associate with what I already know.</p> <p>Then 2 years ago I learned Python and I learned it quite well, Python is easier for me to learn than Ruby. Then since last year, I was trying to learn Ruby, then Rails, and I admit, until now I still couldn't get it, the irony is that those are branded as easy to learn, but for a seasoned programmer like me, I just couldn't associate it with what I learned before, I have 2 books on both Ruby and Rails, and when I'm reading it nothing is absorbed into my mind, and I'm close to giving up...</p> <p>In ruby, I'm having a hard time grasping the concepts of blocks, and why there's @variables that can be accessed by other functions, and what does $variable and :variable do? And in Rails, why there's function like this_is_another_function_that_do_this, so thus ruby, is it just a naming convention or it's auto-generated with thisvariable _can_do_this_function. I'm still puzzled that where all those magic concepts and things came from? And now, 1 year of trying and absorbing, but still no progress...</p> <p><strong>Edit:</strong> To summarize:</p> <ol> <li>How can I learn about blocks, and how can it be related to concepts from PHP/C?</li> <li>Variables, what does does it mean when a variable is prefixed with: <ul> <li>@</li> <li>$</li> <li>:</li> </ul></li> <li>"Magic concepts", suchs as rails declarations of Records, what happens behind the scenes when I write <code>has_one X</code></li> </ol> <p>OK so, bear with me with my confusion, at least I'm honest with myself, and it's over a year now since I first trying to learn ruby, and I'm not getting younger..</p> <p>so </p> <pre><code>I learned this in Bash/C/PHP solve_problem($problem) { if [ -e $problem == "trivial" ]; then write_solution(); else breakdown_problem_into_N_subproblems(\; define_relationship_between_subproblems; for i in $( command $each_subproblem ); do solve_problem $i done fi } write_solution(problem) { some_solution=$(command &lt;parameters&gt; "input" | command); command | command $some_solution &gt; output_solved_problem_to_file } breakdown_problem_into_N_subproblems($problems) { for i in $problems; do command $i | command &gt; i_can_output_a_file_right_away done } define_relationship_between_subproblems($problems) { if [ -e $problem == "relationship" ]; then relationship=$(command; command | command; command;) elsif [ -e $problem == "another_relationship" ]; relationship=$(command; command | command; command;) fi } In C/PHP is something like this solve_problem(problem) { if (problem == trivial) write_solution; else { breakdown_problem_into_N_subproblems; define_relationship_between_subproblems; for (each_subproblem) solve_problems(subproblem); } } </code></pre> <p>And now, I just couldn't connect the dots with Ruby, |b|{ blocks }, using @variables, :variables, and variables_with_this_things..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload