How to use a class

L

Li Chen

Hi guys,

Thank you all for taking your time and replying my previous post.

Now I have other questions: 1) After I write a class with some methods I
want to save the file called test. Which extension is associated with
this file(test.rb or else)? How do I create a new object from the file
called test from another script? (I check the online book of programming
Ruby but just can't find information yet)

2)Which method is used globally for the following substitution ?
s1="AATTCCGG" # original string
s2="TTAAGGCC" # expected string, which means A->T, T->A, C->G, G->C


Li
 
D

David Vallner

--------------enig6252592E9F6CD7950A8E887C
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Li said:
Now I have other questions: 1) After I write a class with some methods = I=20
want to save the file called test. Which extension is associated with=20
this file(test.rb or else)? How do I create a new object from the file =
called test from another script?
=20

You save the file as test.rb, and then in the other file, use:
require 'test'
to be able to use classes in it.
2)Which method is used globally for the following substitution ?
s1=3D"AATTCCGG" # original string
s2=3D"TTAAGGCC" # expected string, which means A->T, T->A, C->G, G-=
C
=20

irb(main):001:0> "AATTCCGG".tr("ATCG", "TAGC")
=3D> "TTAAGGCC"

David Vallner


--------------enig6252592E9F6CD7950A8E887C
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFKYI7y6MhrS8astoRAvorAJ0a/fDYVgSftTX2uZGThjORs5M99QCfZrXz
MwJ60sJ1L6rmeG9B8BVI+TQ=
=zwVm
-----END PGP SIGNATURE-----

--------------enig6252592E9F6CD7950A8E887C--
 
L

Li Chen

David said:
You save the file as test.rb, and then in the other file, use:
require 'test'
to be able to use classes in it.


irb(main):001:0> "AATTCCGG".tr("ATCG", "TAGC")
=> "TTAAGGCC"

David Vallner

Thanks David,

Li
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,214
Messages
2,571,112
Members
47,705
Latest member
noname22

Latest Threads

Top