{"id":6597,"date":"2026-04-13T11:50:42","date_gmt":"2026-04-13T11:50:42","guid":{"rendered":"http:\/\/the-codest.localhost\/dictionary\/immutable-object\/"},"modified":"2026-04-13T11:50:50","modified_gmt":"2026-04-13T11:50:50","slug":"obreytanlegt-fyrirbaeri","status":"publish","type":"dictionary","link":"https:\/\/thecodest.co\/is\/dictionary\/immutable-object\/","title":{"rendered":"\u00d3breytanlegt fyrirb\u00e6ri"},"content":{"rendered":"<h1>Hva\u00f0 er \u00f3breytanlegt forrit?<\/h1>\n<p>\u00d3breytanlegt hlutur er hlutur sem ekki er h\u00e6gt a\u00f0 breyta eftir a\u00f0 hann hefur veri\u00f0 b\u00fainn til. Me\u00f0 \u00f6\u00f0rum or\u00f0um, \u00e1stand hans m\u00e1 ekki breyta eftir a\u00f0 hann hefur veri\u00f0 stofna\u00f0ur. \u00d6ll tilraun til a\u00f0 breyta gildi hans lei\u00f0ir til \u00feess a\u00f0 n\u00fdr hlutur me\u00f0 uppf\u00e6r\u00f0u gildi er b\u00fainn til, en upprunalegi hluturinn helst \u00f3breyttur.<\/p>\n<p>\u00deetta hugtak er oft nota\u00f0 \u00ed <a href=\"https:\/\/thecodest.co\/is\/blog\/top-programming-languages-to-build-e-commerce\/\">forritunarm\u00e1l<\/a> sem sty\u00f0ja virkniforritun, \u00fear sem \u00f3umbreytanleiki er lykilatri\u00f0i. \u00d3umbreytanlegir hlutir eru gagnlegir \u00ed a\u00f0st\u00e6\u00f0um \u00fear sem ekki \u00e1 a\u00f0 breyta \u00e1standi hlutar, til d\u00e6mis \u00ed fj\u00f6l\u00fer\u00e1\u00f0a umhverfi \u00fear sem samt\u00edmilegur a\u00f0gangur a\u00f0 breytilegum hlutum getur leitt til keppnisa\u00f0st\u00e6\u00f0na og <a href=\"https:\/\/thecodest.co\/is\/blog\/app-data-collection-security-risks-value-and-types-explored\/\">g\u00f6gn<\/a> spilling.<\/p>\n<p>\u00d3breytanlegir hlutir hafa nokkra kosti fram yfir breytanlega hluti. \u00cd fyrsta lagi eru \u00feeir \u00fer\u00e1\u00f0\u00f6ruggir og h\u00e6gt er a\u00f0 deila \u00feeim \u00f6rugglega milli \u00fer\u00e1\u00f0a \u00e1n samstillingar. \u00cd \u00f6\u00f0ru lagi er au\u00f0veldara a\u00f0 r\u00f6ksty\u00f0ja \u00fe\u00e1, \u00fear sem \u00e1stand \u00feeirra getur ekki breyst \u00f3v\u00e6nt. \u00cd \u00feri\u00f0ja lagi er h\u00e6gt a\u00f0 nota \u00fe\u00e1 sem lykla \u00ed <a href=\"https:\/\/thecodest.co\/is\/blog\/hash-to-use-or-not-to-use\/\">skr\u00e1<\/a> t\u00f6flur og sett, \u00fear sem hash-gildi \u00feeirra er fast og breytist ekki me\u00f0 t\u00edmanum.<\/p>\n<p>D\u00e6mi um \u00f3breytanlegar hlutir \u00ed <a href=\"https:\/\/thecodest.co\/is\/blog\/find-the-right-java-developer-now\/\">Java<\/a> \u00dear \u00e1 me\u00f0al String, Integer og LocalDate. \u00deegar String-hlutur hefur veri\u00f0 b\u00fainn til er gildi hans ekki h\u00e6gt a\u00f0 breyta. \u00d6ll tilraun til a\u00f0 breyta honum lei\u00f0ir til \u00feess a\u00f0 n\u00fdr String-hlutur me\u00f0 uppf\u00e6r\u00f0u gildi er b\u00fainn til. \u00c1 sama h\u00e1tt, \u00feegar Integer-hlutur hefur veri\u00f0 b\u00fainn til, er gildi hans ekki h\u00e6gt a\u00f0 breyta.<\/p>\n<p>\u00d3breytanlegir hlutir henta \u00fe\u00f3 ekki \u00ed allar a\u00f0st\u00e6\u00f0ur. \u00cd sumum tilfellum eru breytanlegir hlutir hentugri, til d\u00e6mis \u00feegar \u00e1stand hlutar \u00fearf a\u00f0 uppf\u00e6ra reglulega. \u00cd sl\u00edkum tilfellum er mikilv\u00e6gt a\u00f0 samstillta a\u00f0gang a\u00f0 breytanlegum hlutum til a\u00f0 koma \u00ed veg fyrir samkeppnisa\u00f0st\u00e6\u00f0ur og gagnaspillingu.<\/p>\n<p>\u00cd stuttu m\u00e1li er \u00f3breytanlegt hlutur hlutur sem ekki er h\u00e6gt a\u00f0 breyta eftir a\u00f0 hann hefur veri\u00f0 b\u00fainn til. Hann er gagnlegur \u00ed a\u00f0st\u00e6\u00f0um \u00fear sem ekki \u00e1 a\u00f0 breyta \u00e1standi hlutar, til d\u00e6mis \u00ed fj\u00f6l\u00fer\u00e1\u00f0a umhverfi. \u00d3breytanlegir hlutir hafa nokkra kosti fram yfir breytanlega hluti, \u00fear \u00e1 me\u00f0al \u00fer\u00e1\u00f0\u00f6ryggi, au\u00f0veldari r\u00f6khugsun og henta sem lyklar \u00ed hasst\u00f6flum og safnum.<\/p>","protected":false},"excerpt":{"rendered":"<p>L\u00e6r\u00f0u um \u00f3breytanleg forritunara\u00f0ger\u00f0ir: a\u00f0ger\u00f0ir sem ekki er h\u00e6gt a\u00f0 breyta eftir a\u00f0 \u00fe\u00e6r hafa veri\u00f0 b\u00fanar til. Kostirnir eru me\u00f0al annars \u00fer\u00e1\u00f0\u00f6ryggi og au\u00f0veld r\u00f6khugsun.<\/p>","protected":false},"template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"class_list":["post-6597","dictionary","type-dictionary","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Immutable Object - The Codest<\/title>\n<meta name=\"description\" content=\"Learn about immutable objects in programming: objects that cannot be modified once created. Advantages include thread-safety and ease of reasoning.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thecodest.co\/is\/ordabok\/obreytanlegt-fyrirbaeri\/\" \/>\n<meta property=\"og:locale\" content=\"is_IS\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Immutable Object\" \/>\n<meta property=\"og:description\" content=\"Learn about immutable objects in programming: objects that cannot be modified once created. Advantages include thread-safety and ease of reasoning.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thecodest.co\/is\/ordabok\/obreytanlegt-fyrirbaeri\/\" \/>\n<meta property=\"og:site_name\" content=\"The Codest\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-13T11:50:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thecodest.co\/app\/uploads\/2024\/06\/cover-image.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/dictionary\\\/immutable-object\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/dictionary\\\/immutable-object\\\/\",\"name\":\"Immutable Object - The Codest\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\"},\"datePublished\":\"2026-04-13T11:50:42+00:00\",\"dateModified\":\"2026-04-13T11:50:50+00:00\",\"description\":\"Learn about immutable objects in programming: objects that cannot be modified once created. Advantages include thread-safety and ease of reasoning.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/dictionary\\\/immutable-object\\\/#breadcrumb\"},\"inLanguage\":\"is\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/dictionary\\\/immutable-object\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/dictionary\\\/immutable-object\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/thecodest.co\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dictionary\",\"item\":\"https:\\\/\\\/thecodest.co\\\/sv\\\/ordbok\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Immutable Object\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"name\":\"The Codest\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/thecodest.co\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"is\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\",\"name\":\"The Codest\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"is\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/03\\\/thecodest-logo.svg\",\"contentUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/03\\\/thecodest-logo.svg\",\"width\":144,\"height\":36,\"caption\":\"The Codest\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/pl.linkedin.com\\\/company\\\/codest\",\"https:\\\/\\\/clutch.co\\\/profile\\\/codest\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u00d3breytanlegt fyrirb\u00e6ri - The Codest","description":"L\u00e6r\u00f0u um \u00f3breytanleg forritunara\u00f0ger\u00f0ir: a\u00f0ger\u00f0ir sem ekki er h\u00e6gt a\u00f0 breyta eftir a\u00f0 \u00fe\u00e6r hafa veri\u00f0 b\u00fanar til. Kostirnir eru me\u00f0al annars \u00fer\u00e1\u00f0\u00f6ryggi og au\u00f0veld r\u00f6khugsun.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thecodest.co\/is\/ordabok\/obreytanlegt-fyrirbaeri\/","og_locale":"is_IS","og_type":"article","og_title":"Immutable Object","og_description":"Learn about immutable objects in programming: objects that cannot be modified once created. Advantages include thread-safety and ease of reasoning.","og_url":"https:\/\/thecodest.co\/is\/ordabok\/obreytanlegt-fyrirbaeri\/","og_site_name":"The Codest","article_modified_time":"2026-04-13T11:50:50+00:00","og_image":[{"width":1200,"height":675,"url":"https:\/\/thecodest.co\/app\/uploads\/2024\/06\/cover-image.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/thecodest.co\/dictionary\/immutable-object\/","url":"https:\/\/thecodest.co\/dictionary\/immutable-object\/","name":"\u00d3breytanlegt fyrirb\u00e6ri - The Codest","isPartOf":{"@id":"https:\/\/thecodest.co\/#website"},"datePublished":"2026-04-13T11:50:42+00:00","dateModified":"2026-04-13T11:50:50+00:00","description":"L\u00e6r\u00f0u um \u00f3breytanleg forritunara\u00f0ger\u00f0ir: a\u00f0ger\u00f0ir sem ekki er h\u00e6gt a\u00f0 breyta eftir a\u00f0 \u00fe\u00e6r hafa veri\u00f0 b\u00fanar til. Kostirnir eru me\u00f0al annars \u00fer\u00e1\u00f0\u00f6ryggi og au\u00f0veld r\u00f6khugsun.","breadcrumb":{"@id":"https:\/\/thecodest.co\/dictionary\/immutable-object\/#breadcrumb"},"inLanguage":"is","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thecodest.co\/dictionary\/immutable-object\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/thecodest.co\/dictionary\/immutable-object\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thecodest.co\/"},{"@type":"ListItem","position":2,"name":"Dictionary","item":"https:\/\/thecodest.co\/sv\/ordbok\/"},{"@type":"ListItem","position":3,"name":"Immutable Object"}]},{"@type":"WebSite","@id":"https:\/\/thecodest.co\/#website","url":"https:\/\/thecodest.co\/","name":"The Codest","description":"","publisher":{"@id":"https:\/\/thecodest.co\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thecodest.co\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"is"},{"@type":"Organization","@id":"https:\/\/thecodest.co\/#organization","name":"The Codest","url":"https:\/\/thecodest.co\/","logo":{"@type":"ImageObject","inLanguage":"is","@id":"https:\/\/thecodest.co\/#\/schema\/logo\/image\/","url":"https:\/\/thecodest.co\/app\/uploads\/2024\/03\/thecodest-logo.svg","contentUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/03\/thecodest-logo.svg","width":144,"height":36,"caption":"The Codest"},"image":{"@id":"https:\/\/thecodest.co\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/pl.linkedin.com\/company\/codest","https:\/\/clutch.co\/profile\/codest"]}]}},"_links":{"self":[{"href":"https:\/\/thecodest.co\/is\/wp-json\/wp\/v2\/dictionary\/6597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecodest.co\/is\/wp-json\/wp\/v2\/dictionary"}],"about":[{"href":"https:\/\/thecodest.co\/is\/wp-json\/wp\/v2\/types\/dictionary"}],"version-history":[{"count":1,"href":"https:\/\/thecodest.co\/is\/wp-json\/wp\/v2\/dictionary\/6597\/revisions"}],"predecessor-version":[{"id":11002,"href":"https:\/\/thecodest.co\/is\/wp-json\/wp\/v2\/dictionary\/6597\/revisions\/11002"}],"wp:attachment":[{"href":"https:\/\/thecodest.co\/is\/wp-json\/wp\/v2\/media?parent=6597"}],"curies":[{"name":"vp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}