Win*_*ton 5 ruby ruby-on-rails
我来自C,php和bash背景,它很容易学习,因为它们都具有相同的C结构,我可以将其与我已经知道的相关联.
然后2年前我学习了Python并且学到了很多东西,Python比Ruby更容易学习.然后从去年开始,我试图学习Ruby,然后是Rails,我承认,直到现在我仍然无法得到它,具有讽刺意味的是,那些被认为是易于学习的,但对于像我这样经验丰富的程序员,我只是无法将它与我之前学到的东西联系起来,我有两本关于Ruby和Rails的书,当我读到它时,没有什么东西被我的思绪所吸引,我接近放弃......
在ruby中,我很难掌握块的概念,为什么@variables可以被其他函数访问,$ variable和:variable有什么作用呢?在Rails中,为什么有像this_is_another_function_that_do_this这样的函数,所以因此ruby,它只是一个命名约定,或者它是使用此变量_can_do_this_function自动生成的.我仍然感到困惑的是,所有这些神奇的概念和事物都来自哪里?现在,1年的尝试和吸收,但仍然没有进展......
编辑: 总结:
has_one X好吧,请耐心等待我的困惑,至少我对自己诚实,自从我第一次尝试学习红宝石以来已经超过一年了,而且我不会变得更年轻..
所以
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);
}
}
Run Code Online (Sandbox Code Playgroud)
而现在,我只是无法用Ruby,| b | {blocks}连接点,使用@variables,:variables和variables_with_this_things ..
你说你正在读书,所以你可能需要的是:
阅读更少,写得更多.
我也是来自C背景,许多红宝石的概念对我来说完全陌生,但我仍然不理解它们.但不是只阅读我决定写,现在我有几个程序/脚本和网页(甚至相当大),我真的很喜欢红宝石.当你写作时,你将开始"感受"所有这些概念.使用irb来测试你从书本上的知识.用块写一些方法,即使你不理解它们并使用它.
| 归档时间: |
|
| 查看次数: |
819 次 |
| 最近记录: |