Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Loading...
User Settings
close menu
Welcome to Scribd!
Upload
Read for free
FAQ and support
Language (EN)
Sign in
0 ratings
0% found this document useful (0 votes)
46 views
SL Unit 2
Uploaded by
Bhargav Raj
AI-enhanced
Copyright:
© All Rights Reserved
Available Formats
Download
as PDF or read online from Scribd
Download
Save
Save SL unit 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
SL Unit 2
Uploaded by
Bhargav Raj
0 ratings
0% found this document useful (0 votes)
46 views
12 pages
AI-enhanced title
Document Information
click to expand document information
Original Title
SL unit 2
Copyright
© © All Rights Reserved
Available Formats
PDF or read online from Scribd
Share this document
Share or Embed Document
Sharing Options
Share on Facebook, opens a new window
Facebook
Share on Twitter, opens a new window
Twitter
Share on LinkedIn, opens a new window
LinkedIn
Share with Email, opens mail client
Email
Copy link
Copy link
Did you find this document useful?
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Is this content inappropriate?
Report
Copyright:
© All Rights Reserved
Available Formats
Download
as PDF or read online from Scribd
Download now
Download as pdf
Save
Save SL unit 2 For Later
0 ratings
0% found this document useful (0 votes)
46 views
12 pages
SL Unit 2
Uploaded by
Bhargav Raj
AI-enhanced title
Copyright:
© All Rights Reserved
Available Formats
Download
as PDF or read online from Scribd
Save
Save SL unit 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download as pdf
Jump to Page
You are on page 1
of 12
Search inside document
Fullscreen
| a Lo ONT-2 aS nese Ruby : Rulay is a object - oriented reflective, geneval - popese, dyvanite programming dawg vag . “Ruboy was devcloped fo wake Wh act as a Sensthh “ \yatles lug human Proyawiners the widelyirg | conpidiig woulrinety, bk 4s on awhaapreled seriphing Jarguoge which Meer wosk of obs Fmplemeucedtions execute inshructtons ; Bred fredly, withouwe previews ly, compiling a Progreymn. wo wachiue - Sarguage instuckions “Ruby ‘s used to ceale web applications of Belfer sors. - sslbiyie a extend Roky cotth nec ferboes by * vorthtg cde in Ra 4: Once yout shack odehing ty , \oo-level code wrikken ty C, howevey Me possi Eiht \ -d ate endled, ORaby cbiecks m ke + Evething on Ruby RS cin objeck, and abt variables are selerenced Xo objects Most Ruby okies are seprearnted aa C potvlees to an cea Th Memory thot Conlafa the obeectls \ ‘y dara & tur tmplemacketion dekele. i si, C cote, oD Shave veftrences cae vie. variates 4 ar Value , so when wee pos Rat objects unde you LE doh by passing value. ais. yas one exception For Performance reasons, Ruby Aonplemends Fianums, Symbols, teue, false and, Me yl as so-called Smmedtate vodrer, wort ing wa, some dtake okjecks FLXNUMSCvalue) — > von-se10 tf value fs a TnUM Ang SYMBOL ~Pvalue) — snon-ze10 UY value ts arto ms NUL? (vale) 3 Non-zero % value 7s wil REST (value) —y nowzeo 14 value HY neithe Whig, witht re eWorkirg w% sivas! of a wt a nubl- Gn C, we are wsed Ao coor tig desnivaked! stig’: Ruby shirgs, howeved, age more, genreradl Wary well ‘clude embedded nulla. b yew « Ruby shiny objects ase ackually, veferences to an “a Rstiing: sdrudbare, ANE Reig bucket coda ‘ Vet oo Levath © a porides Feld. We com acces the shrucute via Me Robina macros JNTZNUMC rk) 9 Frere oF Bignamt INT ZELK Gt) a Fremum (faster) CHARLEY Char) A Fanum ale sh Sa- newdCohor ¥) 3 String eas C dokskyges t0 Raley obs ects. ai ———< | RSTRING LEN (sta) — len of fhe Ra wy RSTRING — PTR (sb) 3 Petites to sting storage D RSTRIN GAEND (sty) a Poiwhee toed of shig h “Working with other _ekjeds » . When valuc’s are net immediiade, hey ake 4 » pokes ko one of the predefined Ralky objet I Huck es, 4 The she cluces for Whe baste built in claiges Oe defined tx ralaysh % ase named RClarnarne: 4 PAnay RB QtUNRClass, RDaka, RFile, RF lec, Ria, 9, i RObseck, RReger p, Rsting & RStruck, OL™ Sykelor Etovsten + Tukebor eenge —Fodlenfacng, C code usith rub hy and shattrg, dota and behavioy bewoeen, Lhe hog a wordlds “Weagptig c, sbuckurey« a Woke Deda Whap- struct (value cla, veid (+ wat). p Uy, VEAC¥Fce€)07, void. tp) a — Whos the Gen © data ‘ype pee, vegisters tty 5 two aptloage colleckton veutnes 2 vekvons co volue a Pawlet fo a genuine ruby object. Value Dada_make. Shuck (Vakue dass, ¢ (Hark lO), voi A eee) (), CAype #) —Nllocedex ond seks do 2¢10 a struclue of CB ceeieccemceeereee ete ee ENUF LO ve type: void# y mt $ ie grdfcoded ype fiwsh © Yhon proceeds ox pata rap - Stuck, C-Aype es Ye tame of dada sgpe Wok you've wrapping, nol a vasiable of Yet ee ioe. Gek-Stouck (value obj, ctype, ctype *)_ Reus Ae ovtefrad peter. Daka-Gel-Strucl fsa qyesate Weappes around He wero Pata PTRC) wkidy evalluckes he potter. : Obfeck, Creakion me: - Creaking on, okgeck of claw CPPlag er tn our lash, Raley progiarn ¢ N cd = CDPlayes nreto We Implementation of new in clas is Simple, “A allocakes memos for new objeck © then calls! the objeckls ‘Wikialtve method to wwittalize hak +00 MEMO. ) + So, woe need yo Time evck can allocation fane and can entealtee methed. » Mocakion Funchgoncktons = The allocation function ts responsible for creedking | he The memeny “used ky object. Lue “Sf Ake object ‘naplementirg deawt we amy dota oer Han Rub ‘nstavtee variables, neu You don't wed to vworite an alocat ton. function — Rubys Adoutk ablocutor sill usek gush fhe.| Bok th your clare voraps a © shack el) imeed-tc athorate space jor Wed struck fy 7 Mu allocation tunckion. odes Whe ablocabfon fume" qs pared the class of te pol? dbject bebg alected. 4 2 We allecadGon fume’ cveccteg aun ewgly , unin ‘ale|-* ~ted objec , & we nl ko Kill w specific ree + Clonina, dejecks bl All ruby obbjecls can be copied. Msg one of | wo Me\hods cup and clone. Both produce ante inskance of tutr receiver's claw by calling the | * adlocakion funckion | “Then Ahoy copy across amy ‘nstance variables | from tue original. Clee thon goes ta WA further! ! and copfes dnt original's stn fags . Aten CORINA Abe object's ‘instance vaniables, Ye Awdherpreker Tavolees the newd obgells intlealtie COPY meted, pawing Awa velerence lo \he origind okkecl. wo Xoh tne oxiginall object code checless aos oa Ayre of daha and ~ Has a free func’ lh same addict, as cur dvee find. yOu Wa deter claws andcqagtenny, ection nice iq concn, we weed. do allocate memory ino an j “teuton Yok won't be - object shorage | cu lave o& ant bilmap for a boolean bi pie : Sage, oF ak i of . (ele shkucly! als i elk Raley doesn't use Atecy. | L ~ qo work covsectly With the gpeboae colleclor age | As shold Use the following MeN allecation vouktwes Thee voukines do a (Mle Lik more work Yron Yee shovdard matter func! ante y : Lape * AON Co-Lape, ») w —Mocaked w c-Agpe objecls, where Ape ts | \ the eral name of Ma © type « wot a varias | ee le of that Aype- rthey ' 4 Aye #ALLOC Ce-Ayge) | nu ~Mlocader a c-Aype & cals the resulk toa 28 Powder of Wed {ype taltie. » REALLOC-N (van CAyper n) iin ~Reallocates, Mw CAyes 9 ONsiqus the result | to vag 7& prinber do & Vatiable of Age yp type ¥ ALLOCK Ni Ce type a) —Mocale, memory for Wn objecks on Ye stack — thes vne of CAype | img tik Le eatin Il ~odically freed chen he fume’ tect | evokes ALLOCA nt xehouns, uy |= 11D, 2 < PUES Tye Sytent Sve Raby we sely \ew on Mhe Aype Cor clare), at on chiect and more. on IMs capabilites. This «se! 2 oe Knoon ax Duck Typivg- abe sence, Ducle Typing means an objec Nype ws (oe © defined by had th can do, ne by ubat tt te jae Duck Aygo yefers to dhe Vendeneg of Ral io © be Lew foncemed ith the clay of an object a b More Concerned woth whet methods can be called| WW on Hh & chet opetations can, be pesdouned on | ot ss “ha an Ruby, we would use ¥espond_to 1 os oath : Simply ws an okeck fog methed and know “ the an exception ull be xaised 4{ VA ts used ‘mappropriately Mf an obleck uailks MWe oa Auck ard Aabke Lite a duccle, Yon Ve Ruby ‘Indes preter & Veppy fo Wear, wh os ER wee a duck, <4 Br edkeck. cWhelher he object. Adfanes the Aowste mel >> lA Sing! Spend to } G ost) => dive >> Excephton, MEW. vespord_fol (tog) = false (8 >> a. respond? Close) . ae on => false SY gan \ WA HeeqT above eramplg Isddype eb Buck typig. Ua) gk oO okleck quacte hike a Aude Cor ads Like « Be 4 sting), (ust ae ahead €& teak Wh as a duck Comm 7 fang. Wheneses possttle you shoud tread okje cls vccod to voelhods (rey, define rather than the camer from shich toy trhettd o¢ He modules bs, dhe indud e. & Leddy Ruby do Olney o to @)onbeltire Ruby to ha lovguaae® ; Ke hem yor Fes foot ack Some Ruby code, 74 caf cdlle,| vkdy sermind Yeu of othe Prog armed \erequccen Mm we have used. hs This ts becom of the sya ts fandiliad to wees “ at Perl, Padker, and Java ede, wo ed «Lond Cat Ruby © © have We Waalkuy ssumlbiokte vel ‘fonship, p Silat thet ay Wane te uke, 5 . Shiugs ge in doulle- quotes, reac + Shh are mutable a Sovilatltes | wih Cth! as with Cat, in Reuky mel, public, pavate and protected do Sather sobs. Encepons work Mia sre Keyword vank have (ano cent. wy | sVova 8s moduses t's tested And Ws fast. ak mawnier , Yhough the been charged) to protect theQdingy fcow fava Ad ruby , excep Your code Se som ko ahyvine down considietably. we can also expect i not Ab dake lew Ke to knock together quick Protot athe Re. “pate Swilartler: Ac wilh Gave’, Sn Rub in Memory, fs wromaged fox you via a qesbege ~e colechos. et Objecks are skiovalay Ayped. oe “Thoe ae public, private & prclected! melheds, a Bele. | Ake Pad docs ate Awesome, For thee Peers who wl \ovg, fox elegans, objeck ovented (ecdluves built-in closu from ue beefing Rutey can hep. Qs Swslaidies Ae wily Pest an Rul i _ Porerdheses ate often op\ional code Sheings voor barteably the same. ewte wes PHP: ‘ SPHP ts Kefaticaly ny widespread use for eh | appltcadtons, Buc you won Ao use Ruby on aol at lox Aust wank a lanuoge Yakis: move Laglored S | Sos geneva use, Ruby %s voorlh a leek. oa Siwflacea: As tn PHP, in Ruby ot ee call JRuby % dapawtiallly Ayped, Ske Te PHP, & you ; Aon'k need to wooeg about having to declare Bs He Vastables. i a he ee,a Some vastaloles sel with 4, Mike ‘in PHP (Ld Lay not all) 3 ‘ny Baie ou t OM. Paton as ancthes vey nice gered purpose progre xe larquat: salasties: As wrth Pathon, An Ruby, : - shit Yrerals can Span amuliple Liner like Python wage gushed sbings. tiga me ly od Analy There good suppord fov funckionall proguarnnding wth Kash- claws Func\ions, anonymous funckfons anc closures. OQUrbedig o Bike Seeders San addekton +0 extending Ruby by odding c code, rr can also Aun the problem avound~ 2 ented Rude Asel§ willie your exppticect ion, We can *wherack Ruby by C APL ov by oraluatig Skyingg cornet we eal Ateaet ly eabuakig, cbtigs of Ruby coe Ae ee clalere she Ruy eodecpreks, we weed to call uly. aan) Xo Pek up Command ine aagumenhs ¥ by Rady, Ruby intl Stack to sefup He wuby stack, and yuby-inik 4o Gdtaltee the oF“Arlaps ees Asddh. The cath Xo “vuby “inc boefag” end jadds any Mrechorfes to be searched (os Whecrsieg Thés bind of hands-off wranipulatfon of Rub Proqrarns from wily C code Ys €asy, bul 44 has \uoo waios drawbacks. Pra, as evden. “we rave to Weep sto ving Aevys na alckals 7 extrackivg te values trom thoxe alobals out to use whem, — Second, Wl are not Asiy eu seq evyo checking, wich ust dekinndely Whe us - lake, So, We second vay to trlerack Lith Ruby code %s to Use due C APE. Dcond, we veil wlerack kay cvaluaking c APL | “This ves us much fing qratned| combel ¢ takso leks us handle esrors, ble can do {his hy inihetb.lea ag the Swherpeley as Nomal. Then, vetho, than evaluating ctrngs, ‘nslead Invoke specific metheds In yours Ruby | code. Athen “hese methabs velusn your C code gets covtvo | back, Le vor ast pe woke —4 c vor caaill4, “ewibelled xg \ a ae wd abe oe as aderpreker. qhis Junc she we calhe before ony, other wl related functions, ed rath “nih eagle) — Aelkaltees Whe Qs vathalde , mecersand CY your code \cods cou Wlreng rocdules. word wha options Grd asge, cha ean) b — Ges We aby ankerpreler Ye commande copious. Voth vuloy- serfph char % nana) | —scds Me vame of the vulby scfiph fo raw. —leads We queen frle &vdo Ye iwcer preler , a VARA subytunt): ~ Runs we indevpreter ved swhy—frolkret ) — vshuds down ‘he iwdeapreler.
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
Rating: 4 out of 5 stars
4/5 (6025)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
Rating: 4 out of 5 stars
4/5 (626)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
Rating: 4 out of 5 stars
4/5 (1133)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
Rating: 4.5 out of 5 stars
4.5/5 (911)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
Rating: 4.5 out of 5 stars
4.5/5 (1741)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
Rating: 4 out of 5 stars
4/5 (1245)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
Rating: 4 out of 5 stars
4/5 (628)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
Rating: 4 out of 5 stars
4/5 (938)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
Rating: 4.5 out of 5 stars
4.5/5 (548)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
Rating: 4.5 out of 5 stars
4.5/5 (2121)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
Rating: 4.5 out of 5 stars
4.5/5 (359)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
Rating: 4.5 out of 5 stars
4.5/5 (481)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
Rating: 4.5 out of 5 stars
4.5/5 (275)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
Rating: 4.5 out of 5 stars
4.5/5 (821)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
Rating: 4 out of 5 stars
4/5 (1062)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
Rating: 4.5 out of 5 stars
4.5/5 (444)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
Rating: 4 out of 5 stars
4/5 (99)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
Rating: 4.5 out of 5 stars
4.5/5 (273)
Yes Please
From Everand
Yes Please
Amy Poehler
Rating: 4 out of 5 stars
4/5 (1961)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
Rating: 3.5 out of 5 stars
3.5/5 (2283)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
Rating: 4 out of 5 stars
4/5 (1954)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
Rating: 4 out of 5 stars
4/5 (4264)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
Rating: 4.5 out of 5 stars
4.5/5 (1934)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
Rating: 3.5 out of 5 stars
3.5/5 (233)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
Rating: 4.5 out of 5 stars
4.5/5 (235)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
Rating: 4 out of 5 stars
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
Rating: 3.5 out of 5 stars
3.5/5 (141)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
Rating: 3.5 out of 5 stars
3.5/5 (805)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
Rating: 3.5 out of 5 stars
3.5/5 (883)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
Rating: 4 out of 5 stars
4/5 (45)
John Adams
From Everand
John Adams
David McCullough
Rating: 4.5 out of 5 stars
4.5/5 (2520)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
Rating: 3.5 out of 5 stars
3.5/5 (109)
Sci & Tech Booklet - 2 2024
Document
47 pages
Sci & Tech Booklet - 2 2024
Bhargav Raj
No ratings yet
Agriculture by Amit Garg
Document
82 pages
Agriculture by Amit Garg
Bhargav Raj
No ratings yet
046 Success in Prelims 2023 SIP Today's Class Advance PPT at
Document
104 pages
046 Success in Prelims 2023 SIP Today's Class Advance PPT at
Bhargav Raj
No ratings yet
106 Success in Prelims 2023 SIP Today's Class Advance PPT at
Document
67 pages
106 Success in Prelims 2023 SIP Today's Class Advance PPT at
Bhargav Raj
No ratings yet
003) Crisp Copy of Laxmikant
Document
116 pages
003) Crisp Copy of Laxmikant
Bhargav Raj
No ratings yet
065 ©TheOne Calculation Module For Practice - 1 With Answers
Document
56 pages
065 ©TheOne Calculation Module For Practice - 1 With Answers
Bhargav Raj
No ratings yet
Sci & Tech Booklet - 1 2024
Document
48 pages
Sci & Tech Booklet - 1 2024
Bhargav Raj
No ratings yet
847 ©TheOne Class-1 Strategy Simplification BODMAS
Document
91 pages
847 ©TheOne Class-1 Strategy Simplification BODMAS
Bhargav Raj
No ratings yet
021 ©TheOne Mixture and Allegation (Eng)
Document
7 pages
021 ©TheOne Mixture and Allegation (Eng)
Bhargav Raj
No ratings yet
019 ©TheOne Partnership (Eng)
Document
7 pages
019 ©TheOne Partnership (Eng)
Bhargav Raj
No ratings yet
Online Pharmacy Management
Document
7 pages
Online Pharmacy Management
Bhargav Raj
No ratings yet
07 Jan 2024 Test QP
Document
12 pages
07 Jan 2024 Test QP
Bhargav Raj
No ratings yet
Pre Samiksha Test 2 Question Paper
Document
18 pages
Pre Samiksha Test 2 Question Paper
Bhargav Raj
No ratings yet
Pre Samiksha Test-2 Question Paper
Document
20 pages
Pre Samiksha Test-2 Question Paper
Bhargav Raj
No ratings yet
Malware Analyst Professional - Level 1 Syllabus
Document
3 pages
Malware Analyst Professional - Level 1 Syllabus
Bhargav Raj
No ratings yet
Unit 3
Document
68 pages
Unit 3
Bhargav Raj
No ratings yet
B.Tech 4-2 R18 Timetables
Document
22 pages
B.Tech 4-2 R18 Timetables
Bhargav Raj
No ratings yet
Unit 2
Document
48 pages
Unit 2
Bhargav Raj
No ratings yet
Species Static + CA + UPDATED PT@ Clear Vision For UPSC
Document
57 pages
Species Static + CA + UPDATED PT@ Clear Vision For UPSC
Bhargav Raj
No ratings yet
SL Unit 3
Document
24 pages
SL Unit 3
Bhargav Raj
No ratings yet
Social Slow Learner Material EM
Document
106 pages
Social Slow Learner Material EM
Bhargav Raj
No ratings yet
Little Women
From Everand
Little Women
Louisa May Alcott
Rating: 4 out of 5 stars
4/5 (105)