Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "translate to chinese", it's should keep the original content.

This reverts commit da74e72.
  • Loading branch information...
commit 8ed805aee52afb20297b893c28feb235fbcb52a0 1 parent 60bb1a7
@ihower ihower authored
Showing with 51 additions and 32 deletions.
  1. +51 −32 documentation.ruby-from-other-languages.to-ruby-from-python.textile
View
83 documentation.ruby-from-other-languages.to-ruby-from-python.textile
@@ -1,36 +1,55 @@
-Python�O�t�@�ثܴΪ��h�\��γ~�{���y���C�qPython�ഫ��Ruby�A�A�|�o�{�A�ݭn��b��Python���ɭԦh�O�@�ǻy�k�C
+Python is another very nice general purpose programming language.
+Going from Python to Ruby, you'll find that there's a little bit more
+syntax to learn than with Python.
-h3. �ۦ��I
+h3. Similarities
-Ruby�PPython����a��...
-* �P�˦����ʪ����ܾާ@��� (�s�� @irb@).
-* �A�P�˥i�H�ϥΫ�O����Ū���� (Python�ϥ� @pydoc@ ��O�A��Ruby�ϥ� @ri@ ��O).
-* �C��{���X�P�ˤ��ݭn�S�O������Ÿ� (���F�@�몺����)�C
-* �r��i�H��Python���T�޸��r��@�˪���V�h��C
-* ���A���ΨӪ�ܦ�C�A�j�A���ΨӪ�ܦr�嵲�c (�bRuby�٬�"hashes")�C
-* �}�C�ާ@�_�Ӯt���h (�}�C�ۥ[�|���ͤ@�ӧ��}�C, �� @a3 = [ a1, a2 ]@ �o�˪��ާ@�|�^�Ǥ@�ӤG��}�C).
-* ����O�j�κA�ӥB�]���O�ʺA�κA(dynamically typed)�C
-* �Ҧ��F�賣�O����, �ܼƥu�O��V�Y�Ӫ��󪺰Ѧҫ�СC
-* ��������r��M�ݰ_�Ӥ��Ӥ@�ˡA��b�ҥ~�B�z�譱���ާ@�O�t���h���C
-* �P�ˤ]���O�J�������u�� (�bRuby���O is called rdoc).
+As with Python, in Ruby,...
+* There's an interactive prompt (called @irb@).
+* You can read docs on the command line (with the @ri@ command instead
+of @pydoc@).
+* There are no special line terminators (except the usual newline).
+* String literals can span multiple lines like Python's triple-quoted
+strings.
+* Brackets are for lists, and braces are for dicts (which, in Ruby, are called
+"hashes").
+* Arrays work the same (adding them makes one long array, but composing
+them like this @a3 = [ a1, a2 ]@ gives you an array of arrays).
+* Objects are strongly and dynamically typed.
+* Everything is an object, and variables are just references to objects.
+* Although the keywords are a bit different, exceptions work about the same.
+* You've got embedded doc tools (Ruby's is called rdoc).
-h3. �۲��I
-Ruby�PPython���P���a��...
-* �r��O�i�ܰʪ��C
-* �A�i�H�إ߱`�� (�A���Q�n���ܭȪ��ܼ�).
-* ���Ǥj�p�g���ϥκD�� (�Ҧp���O�W�٬O�H�j�g�r��}�Y�A�@���ܼƫh�O�ϥΤp�g�r��}�Y)�C
-* �u���@�ئ�C�e��(�}�C), �ӥB���O�i�ܰʪ��C
-* Ruby����޸��r�ꤹ�\�ϥθ��r��(escape sequences) (�Ҧp \t) �H�ίS�O��"�B���N(expression substitution)"�y�k (�i�H��A�����b�r��̪������JRuby�B��᪺���G�A�Ӥ��ι� @"add " + "strings " + "together"@ ���r��զX)�C��޸��r��h��Python�� @r"raw strings"@�O�@�˪��C
-* �S������"�s��"��"�¦�"�����O�g�k�ARuby�����O�N�u���@�ؼg�k�C
-* �A���Ϊ����s����ݩʡC�bRuby�̡A�o�dz��Omethod calls (You never directly access attributes. With Ruby, it��s all method calls.)
-* �b�I�s��k�ɪ��p�A���q�`�O�i�H�ٲ����C
-* �� @public@, @private@, �H�� @protected@ �T�ؤ覡�ӳ]�w�s��h�šA����Python�̬O���ܼƦW�٫e��[���u���覡��ܡC
-* "�V�J(mixing)"�ΨӴ�N�h���~�ӡC
-* �A�i�H�s�W�έק鷺�ت����O�C��ص{���y�����i�H��A�b���ɾ�o�˪��ק�, ��OPython�|���A�ק鷺�ت����O — Ruby�h�S���o�ӭ���C
-* �ϥ� @true@ �H�� @false@ �Ӥ��O @True@ �� @False@ (Python�̪�@None@ �bRuby�h�O @nil@).
-* �b��ե��L�Ȫ��u���ɡA�u�� @false@ �� @nil@ �|�o�찲���ȡA�䥦�Ҧ������|�o��u�ȡC(�]�A @0@, @0.0@, @""@, �H�� @[]@).
-* Ruby�ϥ� @elsif@ �Ӥ��O @elif@.
-* Ruby�ϥ� @require@ �Ӥ��O @import@�A��ϥΤW��Python�O�@�˪��C
-* �ΨӲ��ͤ�󪺵�ѳq�`�g�b���e��_�W��_ (�Ӥ���docstrings�O�g�b�U��)�C
-* Ruby���\�h�����|�i�H��A�ϥΡA��M�A�ݭn���h�ɶ��h�O�СA�A�٬O�i�H�ܧ֪��Ƿ|�C�o�DZ��|�|��Ruby�ܱo�󦳽�ӥB�󦳥Ͳ��O�C
+h3. Differences
+
+Unlike Python, in Ruby,...
+* Strings are mutable.
+* You can make constants (variables whose value you don't intend to change).
+* There are some enforced case-conventions (ex. class names start
+with a capital letter, variables start with a lowercase letter).
+* There's only one kind of list container (an Array), and it's mutable.
+* Double-quoted strings allow escape sequences (like \t) and
+a special "expression substitution" syntax (which allows you to insert
+the results of Ruby expressions directly into other strings without
+having to @"add " + "strings " + "together"@). Single-quoted strings
+are like Python's @r"raw strings"@.
+* There are no "new style" and "old style" classes. Just one kind.
+* You never directly access attributes. With Ruby, it's all method calls.
+* Parentheses for method calls are usually optional.
+* There's @public@, @private@, and @protected@ to enforce access, instead
+of Python's @_voluntary_@ underscore @__convention__@.
+* "mixin's" are used instead of multiple inheritance.
+* You can add or modify the methods of built-in classes. Both languages let you open up and modify classes at any point, but Python prevents modification of built-ins — Ruby does not.
+* You've got @true@ and @false@ instead of @True@ and @False@ (and @nil@
+instead of @None@).
+* When tested for truth, only @false@ and @nil@ evaluate to a false value.
+Everything else is true (including @0@, @0.0@, @""@, and @[]@).
+* It's @elsif@ instead of @elif@.
+* It's @require@ instead of @import@. Otherwise though, usage is the same.
+* The usual-style comments on the line(s) _above_ things (instead of
+docstrings below them) are used for generating docs.
+* There are a number of shortcuts that, although give you more to
+remember, you quickly learn. They tend to make Ruby fun and very
+productive.
+
Please sign in to comment.
Something went wrong with that request. Please try again.