我來自C,php和bash背景,很容易學習,因爲它們都具有相同的C結構,我可以將其與我已知的相關聯。這個C和PHP程序員如何學習Ruby和Rails?
然後2年前我學會了Python,並且我學得很好,Python比Ruby更容易學習。然後從去年開始,我試圖學習Ruby,然後Rails,並且我承認,直到現在,我仍然無法得到它,具有諷刺意味的是,這些標籤容易學習,但對於像我這樣經驗豐富的程序員來說,我只是不能將它與我以前學過的東西聯繫起來,我有兩本關於Ruby和Rails的書,而當我讀它時,沒有什麼會被吸收到我的腦海中,而我正在接近放棄......
在ruby中,我很難理解塊的概念,爲什麼存在可以被其他函數訪問的@變量,以及$ variable和:variable是做什麼的?在Rails中,爲什麼會有像this_is_another_function_that_do_this這樣的函數,因此ruby,它只是一個命名約定,或者它是用這個變量_can_do_this_function自動生成的。我仍然感到困惑,所有這些神奇的概念和事物都來自哪裏?而現在,1年的努力,吸收,但仍然沒有進展......
編輯: 總結:
- 我如何瞭解塊,怎麼能涉及到的概念來自PHP/C?
- 變量,什麼是它的意思是當一個變量與前綴:
- @
- $
- :
- 「魔術概念」,suchs作爲軌道記錄的聲明,是什麼當我寫在幕後發生
has_one X
好吧,承受我的困惑,至少我「M誠實面對自己,現在超過一年,因爲我第一次嘗試學習Ruby和我不再年輕..
所以
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 <parameters> "input" | command);
command | command $some_solution > output_solved_problem_to_file
}
breakdown_problem_into_N_subproblems($problems) {
for i in $problems;
do
command $i | command > 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);
}
}
而現在,我只是無法連接Ruby,| b | {blocks},使用@variables,變量和variables_with_this_things。
C沒有全局性 – horseyguy 2010-03-11 12:24:33
Thei're全球性在「外部」的意義上,許多脂肪酶稱他們爲「全球」。 http://en.wikipedia.org/wiki/Global_variable – clyfe 2010-03-11 15:10:54
它有文件範圍,當然,但不是'全球範圍'。不能從其他翻譯單元訪問,例如 – horseyguy 2010-03-12 13:55:05