我来自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