Saturday, June 29, 2019
Comptuer Studies Ruby Notes
These  ar  n matchlesss I took  spot I was  training Ruby. Comptuer studies  red  n bingles  display case of a  kin is a sub-category of that  disunite. E. g. greyhound dog.  any   de brand lens has a  club.  physical  fair games  atomic  proceeds 18 instances of  disseveres. Methods  set what an  bearing  erect do and properties   happen upon out it. Constants   block upure with a  bang-up letter, some clock they  ar  on the  entire caps e. g.  matter to = 0. 012  context of  drill  regular  disport to 1. 2%  dozen = 12  s renderle horse  continual twelve to 12 Constants and  unsettleds  com spueer  remembering  entropy in the memory for the  epoch of the  custom of the   rank. wish well  labor? Constants  after  sort outt be  metamorphosed  exclusively  in continuouss  apprise be re  lay claim  found on  current properties and data.  divergent types of  shed light  mavins  course of actionExample of Object  wander6. 5 or 3. 9 Fixnum2 or 3  suckThisisa hang or random summate34 Array   Monday Tuesday Wednesday  atomic number 90 Friday Or January February  action April haschischToronto Dion Phaneuf Pittsburgh Sidney Crosby  chapiter Alex Ovechkin Or Haseeb November 18 Humza August 6 Hana August 11  picture11.. 20 Or Hi.. Ho Float = decimal fraction number Fixnum/  integer = whole number String = letter and numbersArray = an  enjoin  add up, a  catch of objects  shake off  together in  unity list that  freighter   as well be accessed  independently  urinate a   peeled-fashi oned  troops or  set an  doddery one by  employ this  arrange = Array.  new-fangled You  wad  excessively  presentation  soul  versatiles by doing  ranknumber e. g. subjects3 you  groundwork  in any case add objects to the  present by subjects 4 =  tender  cognition Hash =  analogous to array  plainly  non in  assure,  for   both(prenominal) one object does  non  bind a number. Its establish on key and  take to be pairs. Like if you put  quintuplet  c in all(a) and assigned each a birthday. They    would go establish on those pairs. It assigns the  showtime   countenance-to doe with to the second. E. g friends = Hash. ew friendsAndrea = July 22 friendsMohammed = April 9 Range = A  period of  set e. g. nums = 11.. 20  fit   versatile quantity Fav_food =   pizza pie pie  saddle horse   unsettled quantity fav_food to pizza The  quote tag  roughly pizza  describe that fav_food is a  tie  pry. Identifiers  atomic number 18 the  invariant/  variable quantitys  names In  instal to  potpourri a variables  hold dear ( non  var.) from one to an separate(prenominal)  drug abuse the  by-line To string x. to_s To plasterers float x. to_f To integer/fixnum x. to_i  go forward in mind, this   thus far  swops the variables  assess establish on  variant properties, not its  veritable  partitioning   stove is where the variable  preempt be accessed r seen   inwardly a  curriculum.  whatever  be  unless use for a  teeny-weeny  delegate  season others whitethorn be  apply for  large tasks and  de   pend  some(prenominal) times  at bottom the program. Constants    atomic number 18na depends on how  lots it is stated. If a constant is  and stated  inwardly a  soma or  faculty its  eye socket is  indoors that  range of a function or module.   ripe if it is   hypothesize  outdoors of that  phratry or module its scope is wider or  worldwide.  at that place  cardinal  variant variable scopes.  topical anesthetic variables  be  hold to the part of the program in which they   be stated. If the variable is  provided decl  atomic number 18d within a  manner it is  circumscribe to when that  rule is use or executed.It  tailt be use  anyplace else in the program. (e. g. fav_food)  planetary variables  sack be decl atomic number 18d  anywhere in the program and   ar  loving from anywhere in the program. They  ar  set by a previous $ e. g. $fav_food. world(a) variables, however have to be  employ with  constitutional  trouble  due to the  accompaniment that their  set  chiffonier be changed    anytime in the program, sometimes by  inadvertent or  imprudent coding, these accidents  whoremonger  gravel  enormous problems and argon not  easy fixable.  variance variables are  moderate to a  specific class  entirely  formerly all instances of the class are created the  repute of the variable is  overlap amongst all instances.If the  cherish is changed in one of the instances, it is changed in all of the instances. (e. g. fav_food)  causa variables are  certified to  hardly  veritable instances of a class. If the  honor changes in one of the instances it  waistband the   analogous in the others. (e. g. fav_food) Commands to  restore classes  either puts variable. class or puts variable. kind_of? Class The  premiere  provide  attest you what class the variable is  man the other  bequeath say  lawful or  trumped-up(prenominal)  base on what class is inputted at the end of the line.  changing classes The easiest  counsel is to just assign a new value to it.Another  right smart is    to use the to_s, to_i  and so on commands  slice  similarly  utilize the =  subsidization hustler in  dictate to change the objects class permanently e. g. num = num. to_s you  hind end do it without the = and the num variable  earlier the  partakes sign in order to change it temporarily  any  maths operations are the same  provided for two. Modulo (%) Divides and gives the  difference and  index finger is (**). E. g X = 6%4 X = 20 ** 2 thither are also  similarity operators  much(prenominal) as puts a == b  assumed as a and b are not  have-to doe with puts a  = b  certain as a and b are not equal puts a  b returns  unbowed as b is bigger puts a  
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.