{"id":9574,"date":"2021-02-25T09:00:00","date_gmt":"2021-02-25T16:00:00","guid":{"rendered":"https:\/\/swimlane.com\/resource\/union-types\/"},"modified":"2026-02-04T21:50:46","modified_gmt":"2026-02-05T04:50:46","slug":"tipos-de-union","status":"publish","type":"sw_resource","link":"https:\/\/swimlane.com\/es\/blog\/union-types\/","title":{"rendered":"No preguntes qu\u00e9 pueden hacer por ti los sindicalistas; pregunta qu\u00e9 puedes hacer t\u00fa por ellos."},"content":{"rendered":"\n\n\n<section class=\"bs-section bs-section-50ac0cc438dbf2f3b380783c05a3c736bb0670e7 bs-section---default bs-section--blog-inner-banner  \"><style>.bs-section.bs-section-50ac0cc438dbf2f3b380783c05a3c736bb0670e7{ background-color: #000743;} <\/style><div class=\"container\">\n<div class=\"bs-row row  flex-md-row-reverse bs-row---default\">\n<div class=\" bs-column col-sm-12 col-md-12 col-lg-6   bs-column-6770b3369b6c61539d3140cb52ed6bc5ec393625 bs-column---default bs-column--right d-flex flex-column justify-content-end    \"><figure class=\"wp-block-post-featured-image\"><img decoding=\"async\" src=\"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"Two figures pushing cube and cylinder shapes, symbolizing process comparison\" style=\"object-fit:cover;\" srcset=\"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png 1120w, https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes-300x186.png 300w, https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes-1024x636.png 1024w, https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes-768x477.png 768w\" sizes=\"(max-width: 1120px) 100vw, 1120px\" \/><\/figure><\/div>\n\n\n\n<div class=\" bs-column col-sm-12  col-md-12 col-lg-6   bs-column-2ba18c9b6304620af4785b54fe900bf0ce0fc4d5 bs-column---default d-flex flex-column    \"><div class=\"wp-block-post-date\"><time datetime=\"2021-02-25T09:00:00-07:00\">Feb 25, 2021<\/time><\/div>\n\n<h1 class=\"wp-block-post-title has-text-color has-white-color\">Ask Not What Union Types Can Do For You; Ask What You Can Do to Union Types<\/h1>\n\n\n<div class=\"bs-div bs-div-44a15e4b99450b7aaf810333a0fbaa4ff5112133 bs-div---default\"><div class=\"bs-div__inner d-flex flex-wrap align-items-center    \">\n<a class=\"bs-post__author has-text-align-center\" href=\"https:\/\/swimlane.com\/es\/author\/Katie_Bykowski\/\">\n\t<div class=\"profile-desc\">\n\t\t<figure>\n\t\t\t<img decoding=\"async\" src=\"https:\/\/swimlane.com\/wp-content\/uploads\/author_Katie_Bykowski.jpg\" alt=\"user-avatar\">\n\t\t<\/figure>\n\t\t<span class=\"prefix\"><\/span>\n\t\t<span class=\"name\">\n\t\t\tKatie Bykowski\t\t<\/span>\n\t<\/div>\n<\/a>\n\n\n\n<div class=\"reading-time\">\n    <span class=\"reading-time__time\">3 <\/span> Minute Read\n<\/div><\/div><\/div>\n<\/div>\n<\/div>\n<\/div><\/section>\n\n\n\n\n\n\n\n\n\n<section class=\"bs-section bs-section-205a03f93391472c82564395e3b5684e68c8ef7d bs-section---default bs-section--blog-inner-main-contents  \"><div class=\"container\">\n<div class=\"bs-row row justify-content-between  bs-row---default\">\n<div class=\" bs-column col-sm-12 col-md-1   bs-column-fa02c15a19a9c2952663733986e45d4eef708638 bs-column---default     \"><div class=\"heateor_sss_sharing_container heateor_sss_horizontal_sharing\" data-heateor-ss-offset=\"0\" data-heateor-sss-href='https:\/\/swimlane.com\/es\/blog\/union-types\/'><div class=\"heateor_sss_sharing_ul\"><a aria-label=\"Email\" class=\"heateor_sss_email\" href=\"https:\/\/swimlane.com\/es\/blog\/union-types\/\" onclick=\"event.preventDefault();window.open('mailto:?subject=' + decodeURIComponent('Ask%20Not%20What%20Union%20Types%20Can%20Do%20For%20You%3B%20Ask%20What%20You%20Can%20Do%20to%20Union%20Types').replace('&', '%26') + '&body=https%3A%2F%2Fswimlane.com%2Fes%2Fblog%2Funion-types%2F', '_blank')\" title=\"Email\" rel=\"noopener\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#649a3f;width:35px;height:35px;border-radius:999px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;border-radius:999px;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"-.75 -.5 36 36\"><path d=\"M 5.5 11 h 23 v 1 l -11 6 l -11 -6 v -1 m 0 2 l 11 6 l 11 -6 v 11 h -22 v -11\" stroke-width=\"1\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><a aria-label=\"Twitter\" class=\"heateor_sss_button_twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?text=Ask%20Not%20What%20Union%20Types%20Can%20Do%20For%20You%3B%20Ask%20What%20You%20Can%20Do%20to%20Union%20Types&url=https%3A%2F%2Fswimlane.com%2Fes%2Fblog%2Funion-types%2F\" title=\"Twitter\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_twitter\" style=\"background-color:#55acee;width:35px;height:35px;border-radius:999px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;border-radius:999px;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"-4 -4 39 39\"><path d=\"M28 8.557a9.913 9.913 0 0 1-2.828.775 4.93 4.93 0 0 0 2.166-2.725 9.738 9.738 0 0 1-3.13 1.194 4.92 4.92 0 0 0-3.593-1.55 4.924 4.924 0 0 0-4.794 6.049c-4.09-.21-7.72-2.17-10.15-5.15a4.942 4.942 0 0 0-.665 2.477c0 1.71.87 3.214 2.19 4.1a4.968 4.968 0 0 1-2.23-.616v.06c0 2.39 1.7 4.38 3.952 4.83-.414.115-.85.174-1.297.174-.318 0-.626-.03-.928-.086a4.935 4.935 0 0 0 4.6 3.42 9.893 9.893 0 0 1-6.114 2.107c-.398 0-.79-.023-1.175-.068a13.953 13.953 0 0 0 7.55 2.213c9.056 0 14.01-7.507 14.01-14.013 0-.213-.005-.426-.015-.637.96-.695 1.795-1.56 2.455-2.55z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><a aria-label=\"Facebook\" class=\"heateor_sss_facebook\" href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fswimlane.com%2Fes%2Fblog%2Funion-types%2F\" title=\"Facebook\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#0765FE;width:35px;height:35px;border-radius:999px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;border-radius:999px;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M28 16c0-6.627-5.373-12-12-12S4 9.373 4 16c0 5.628 3.875 10.35 9.101 11.647v-7.98h-2.474V16H13.1v-1.58c0-4.085 1.849-5.978 5.859-5.978.76 0 2.072.15 2.608.298v3.325c-.283-.03-.775-.045-1.386-.045-1.967 0-2.728.745-2.728 2.683V16h3.92l-.673 3.667h-3.247v8.245C23.395 27.195 28 22.135 28 16Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"Linkedin\" class=\"heateor_sss_button_linkedin\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fswimlane.com%2Fes%2Fblog%2Funion-types%2F\" title=\"Linkedin\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_linkedin\" style=\"background-color:#0077b5;width:35px;height:35px;border-radius:999px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;border-radius:999px;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path d=\"M6.227 12.61h4.19v13.48h-4.19V12.61zm2.095-6.7a2.43 2.43 0 0 1 0 4.86c-1.344 0-2.428-1.09-2.428-2.43s1.084-2.43 2.428-2.43m4.72 6.7h4.02v1.84h.058c.56-1.058 1.927-2.176 3.965-2.176 4.238 0 5.02 2.792 5.02 6.42v7.395h-4.183v-6.56c0-1.564-.03-3.574-2.178-3.574-2.18 0-2.514 1.7-2.514 3.46v6.668h-4.187V12.61z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><\/div><div class=\"heateorSssClear\"><\/div><\/div>\n<\/div>\n\n\n\n<div class=\" bs-column col-sm-12  col-lg-8 col-md-11   bs-column-0d83d6d9863f92131cc95492d42e5b50c72f00bb bs-column---default bs-column--contents     \">\n<h2>Union types are useful when you have a collection of classes that do not act, but must all be acted upon in the same way.<\/h2>\n<p>As a software developer at Swimlane, I sometimes get the opportunity to learn new things that benefit not only me and the rest of the team, but also make our products more effective. In a recent project I was working on, I was tasked to add an Audit Log. The requirement was to record every change (e.g. Create, Update, Delete) to any of our database collections in a new collection, AuditLog, and label each record with the action that had occurred. Simple enough.<\/p>\n<p>However, Update actions posed a complication: Different objects in the workflow engine can be updated in different ways (e.g., users can be enabled, disabled or logged in; plugins can be upgraded), and I didn\u2019t want to clutter the Update functions themselves with logging logic. I needed to write a function that took as arguments the before and after state of the document being modified. Then, based on the changes in the document, determine the action that had modified them. But what type should the before and after arguments be?<\/p>\n<pre>class AuditLogsService {\nasync log(before: ???, after: ???): Promise&lt;void&gt; {\n\/\/...\n}\n}<\/pre>\n<p>One solution would have been to use an interface. Our documents don\u2019t already implement a base class or an interface, so this sounded simple. Create a BaseDocument interface and make all eight document classes implement it. Then before and after can be typed to the interface.<\/p>\n<pre>interface AuditLogable {}\n<\/pre>\n<p>The problem with that solution is that the interface would be meaningless because none of the document classes share any properties or have any methods. Well, that\u2019s not entirely true &#8211; they share an \u201cid\u201d field. So I\u2019d be modifying eight different classes just to implement an interface with a single property and no methods.<\/p>\n<pre>interface AuditLogable {\nid: string;\n}<\/pre>\n<p>What about adding the log method to the interface and allowing each document type to define its own logging behavior? That\u2019s proper object orientation, isn\u2019t it? Except now I have to implement eight logging methods, each with mostly similar behavior. Why don\u2019t I use a base class instead of an interface to DRY (Don\u2019t Repeat Yourself) things out? Because each logging method\u2019s behavior is only <em>mostly<\/em> similar. Plugins, for example, are the only document type that don\u2019t have a \u201ccreate\u201d action. Instead, we call it \u201cinstall\u201d.<\/p>\n<p>I realized that I was approaching this problem backwards. Documents should not do the audit logging, they should have the audit logging done to them. That way I could write it all in a single function without implementing any meaningless interfaces or confusing abstraction.<\/p>\n<p>Fortunately, Typescript has a simple way to construct this pattern: Union Types. With a union type, I don\u2019t need to abstract out any properties or behavior. I can effectively say,<\/p>\n<pre>\u201cArgument \u2018before\u2019 is one of any of the types that can be audit logged.\u201d \ntype AuditLogable = User | Plugin | Playbook; \/\/ \u2026\nclass AuditLogsService {\nasync log(before: AuditLogable, after: AuditLogable): Promise&lt;void&gt; {\n\/\/...\n}\n}<\/pre>\n<p>Because type information is lost at runtime, I also need to pass an additional parameter indicating which type from within the union I am passing as the before and after arguments.<\/p>\n<pre>enum SwimType = {\nuser,\nplugin,\nplaybook,\n\/\/ ...\n}\nclass AuditLogsService {\nasync log(before: AuditLogable, after: AuditLogable, type: SwimType): Promise&lt;void&gt; {\n\/\/...\n}\n}<\/pre>\n<p>Now I\u2019ve implemented AuditLogging with a single function and one new Union Type. None of the documents being logged need to be modified, so adding a new class to the logger is as simple as adding it to AuditLogable and adding any additional required behavior to the single log function. Everything is easy to test, and easy to understand.<\/p>\n<\/div>\n\n\n\n<div class=\" bs-column col-sm-12  col-md-12 col-lg-3   bs-column-0ad64702520e52820989c3b8a4a5574abd826112 bs-column---default     \">\n<div class=\"bs-div bs-div-f0851be86a4542da358c10ec17ccebffa17efe07 bs-div---default bs-div--tags\"><div class=\"bs-div__inner     \">\n<h2 class=\"wp-block-heading\" id=\"h-tags\">Tags<\/h2>\n\n\n<div class=\"post-tag-wrapper\">\n    <p><\/p><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"bs-div bs-div-5e7267355d8caf36f5b5e0c86eef387b664b848d bs-div---default bs-div--related-posts\"><div class=\"bs-div__inner     \">\n<h2 class=\"wp-block-heading\" id=\"h-related-posts\">Related Posts<\/h2>\n\n\n\n<div class=\"bs-related-posts bs-related-posts-block---default\"><div class=\"bs-related-posts__container\"><div class=\"bs-related-posts__items\">\n<div class=\" bs-column col-sm-4   bs-column-b619eb984092e720779a969a873521d2ec1a85a5 bs-column---default     \">\t\t\t\t\t<div class=\"bs-post bs-post-69e3a7d7170b7 bs-single-post---default enable\" >\n\t\t\t<a class=\"bs-post__trigger\" href='https:\/\/swimlane.com\/es\/blog\/why-you-need-a-true-soar-solution-for-your-business-needs-not-just-secops\/' target='_self'>\t\t\t<div class=\"bs-post__inner\">\n\t\t\t\t<div class=\"bs-post__details\">    <div class=\"bs-post__date\">\n        <span>May 19, 2021<\/span>\n    <\/div>\n    <div class=\"bs-post__title\">\n        <h5>Why You Need a True SOAR Solution for Your Business Needs, Not Just SecOps<\/h5>\n    <\/div>\n<div class=\"bs-post__learn-more\">\n    <span class='btn learn-more-text bs-post__learn-more-text'>Read More<\/span><\/div>\n<\/div>\t\t\t<\/div>\n\t\t\t<\/a>\t\t<\/div>\n\t<\/div>\n\n\n\n<div class=\" bs-column col-sm-4   bs-column-b619eb984092e720779a969a873521d2ec1a85a5 bs-column---default     \">\t\t\t\t\t<div class=\"bs-post bs-post-69e3a7d718328 bs-single-post---default enable\" >\n\t\t\t<a class=\"bs-post__trigger\" href='https:\/\/swimlane.com\/es\/blog\/when-to-automate-security\/' target='_self'>\t\t\t<div class=\"bs-post__inner\">\n\t\t\t\t<div class=\"bs-post__details\">    <div class=\"bs-post__date\">\n        <span>May 23, 2024<\/span>\n    <\/div>\n    <div class=\"bs-post__title\">\n        <h5>When to Automate and When Not to Automate Security<\/h5>\n    <\/div>\n<div class=\"bs-post__learn-more\">\n    <span class='btn learn-more-text bs-post__learn-more-text'>Read More<\/span><\/div>\n<\/div>\t\t\t<\/div>\n\t\t\t<\/a>\t\t<\/div>\n\t<\/div>\n\n\n\n<div class=\" bs-column col-sm-4   bs-column-b619eb984092e720779a969a873521d2ec1a85a5 bs-column---default     \">\t\t\t\t\t<div class=\"bs-post bs-post-69e3a7d7191ae bs-single-post---default enable\" >\n\t\t\t<a class=\"bs-post__trigger\" href='https:\/\/swimlane.com\/es\/blog\/outside-of-soc\/' target='_self'>\t\t\t<div class=\"bs-post__inner\">\n\t\t\t\t<div class=\"bs-post__details\">    <div class=\"bs-post__date\">\n        <span>Abr 26, 2022<\/span>\n    <\/div>\n    <div class=\"bs-post__title\">\n        <h5>Outside of the SOC: Use Cases not to Underestimate<\/h5>\n    <\/div>\n<div class=\"bs-post__learn-more\">\n    <span class='btn learn-more-text bs-post__learn-more-text'>Read More<\/span><\/div>\n<\/div>\t\t\t<\/div>\n\t\t\t<\/a>\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div>\n<\/div><\/div>\n\n\n<\/div>\n<\/div>\n<\/div><\/section>\n\n\n\n<section class=\"bs-section bs-section-2a4a600ae9ab197b6a4ccafe05152bf1a2fde1d1 bs-section---default bs-section--newsletter bs-section--common-marketo-form bs-section--common-marketo-form-two-columns  \"><style>.bs-section.bs-section-2a4a600ae9ab197b6a4ccafe05152bf1a2fde1d1{ background-color: #000743;} <\/style><div class=\"container-fluid\">\n<div class=\"bs-row row   bs-row---default\">\n<div class=\" bs-column col-sm-0 col-md-0 col-lg-6   bs-column-df5e10bef85c15055718b4d93887855962017939 bs-column---default     \">\n<h2 class=\"wp-block-heading has-white-color has-text-color\" id=\"requestor\">Request a Live Demo<\/h2>\n<\/div>\n\n\n\n<div class=\" bs-column col-sm-0 col-md-0 col-lg-6   bs-column-df5e10bef85c15055718b4d93887855962017939 bs-column---default     \"><div class='media-elements bs-media-element---default enable'>    <div class='bs-common-image'>\n                            <figure class='figure justify-content-start d-flex'>\n                            <picture>\n                            \n                            <img src='https:\/\/swimlane.com\/wp-content\/uploads\/liitp.svg' class='img-fluid'   alt='' title=''  \/>\n                            <\/picture>\n                                \n                            <\/figure>\n                        <\/div><\/div>\n\n<script src=\"\/\/pages.swimlane.com\/js\/forms2\/js\/forms2.min.js\"><\/script>\n<form id=\"mktoForm_1017\"><\/form>\n<script>\n    var embeddedFormId = '05a6905d0187a23e165b2fd995e965fe15cb94f6';\n    var marketoBaseUrl = '\/\/pages.swimlane.com';\n    var munchkinId = '978-QCM-390';\n    var formId = '1017';\n    var responseType = 'redirect';\n    var responseMessage = 'Thank you!';\n    var redirectURL = '';\n    var downloadFileURL = '';\n    var linkOpenType = '_self';\n    var popupVideo = 'url';\n    var popupVideoURL = '';\n    var popupVideoUploadURL = '';\n    MktoForms2.loadForm(marketoBaseUrl, munchkinId, formId, function(form) {\n        form.onSuccess(function(values, followUpUrl) {\n            document.getElementById(\"int_mktoForm_\" + formId).innerHTML = responseMessage;\n                    });\n    });\n<\/script>\n<div class=\"form-submit-note\" id=\"int_mktoForm_1017\"><\/div>\n<!-- Incluing form response options -->\n\n\n\n<script>\n    (function() {\n        \/\/ Please include the email domains you would like to block in this list\n        var invalidDomains = [\"@gmail.\", \"@yahoo.\", \"@hotmail.\", \"@live.\", \"@icloud.\",\"@aol.\", \"@outlook.\", \"@proton.\", \"@mailinator.\"];\n\n\n        MktoForms2.whenReady(function(form) {\n            form.onValidate(function() {\n                var email = form.vals().Email;\n                if (email) {\n                    if (!isEmailGood(email)) {\n                        form.submitable(false);\n                        var emailElem = form.getFormElem().find(\"#Email\");\n                        form.showErrorMessage(\"Must be Business email.\", emailElem);\n                    } else {\n                        form.submitable(true);\n                    }\n                }\n            });\n        });\n\n        function isEmailGood(email) {\n            for (var i = 0; i < invalidDomains.length; i++) {\n                var domain = invalidDomains[i];\n                if (email.indexOf(domain) != -1) {\n                    return false;\n                }\n            }\n            return true;\n        }\n\n\n    })(); \n<\/script>\n<\/div>\n<\/div>\n<\/div><\/section>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":9575,"template":"","meta":{"_acf_changed":false,"show_custom_date":false,"custom_date":"","featured":false,"featured_image":0,"learn_more_label":"","image_alt_text":"","learn_more_type":"","learn_more_link":[],"show_popup":false,"disable_iframe":false,"enable_lazy_loading":false,"learn_more_link_file":0,"event_date":false,"event_start_date":"","event_end_date":"","featured_page_list":[],"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","inline_featured_image":false,"footnotes":""},"tags":[],"resource-type":[67],"resource-topic":[],"resource-industry":[],"blog-category":[],"class_list":["post-9574","sw_resource","type-sw_resource","status-publish","has-post-thumbnail","hentry","resource-type-blogs"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.5 (Yoast SEO v27.1.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Ask Not What Union Types Can Do For You; Ask What You Can Do to Union\u2026<\/title>\n<meta name=\"description\" content=\"Union types are useful when you have a collection of classes that do not act, but must all be acted upon in the same way. As a software developer at\u2026\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swimlane.com\/es\/blog\/tipos-de-union\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ask Not What Union Types Can Do For You; Ask What You Can Do to Union Types\" \/>\n<meta property=\"og:description\" content=\"Union types are useful when you have a collection of classes that do not act, but must all be acted upon in the same way. As a software developer at\u2026\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swimlane.com\/es\/blog\/tipos-de-union\/\" \/>\n<meta property=\"og:site_name\" content=\"AI Security Automation\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-05T04:50:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1120\" \/>\n\t<meta property=\"og:image:height\" content=\"696\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@swimlane\" \/>\n<meta name=\"twitter:label1\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/\",\"url\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/\",\"name\":\"Ask Not What Union Types Can Do For You; Ask What You Can Do to Union\u2026\",\"isPartOf\":{\"@id\":\"https:\/\/swimlane.com\/es\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png\",\"datePublished\":\"2021-02-25T16:00:00+00:00\",\"dateModified\":\"2026-02-05T04:50:46+00:00\",\"description\":\"Union types are useful when you have a collection of classes that do not act, but must all be acted upon in the same way. As a software developer at\u2026\",\"breadcrumb\":{\"@id\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/swimlane.com\/es\/blog\/union-types\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/#primaryimage\",\"url\":\"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png\",\"contentUrl\":\"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png\",\"width\":1120,\"height\":696,\"caption\":\"Two figures pushing cube and cylinder shapes, symbolizing process comparison\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/swimlane.com\/es\/blog\/union-types\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/swimlane.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ask Not What Union Types Can Do For You; Ask What You Can Do to Union Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/swimlane.com\/es\/#website\",\"url\":\"https:\/\/swimlane.com\/es\/\",\"name\":\"Low-Code Security Automation & SOAR Platform | Swimlane\",\"description\":\"Agentic AI automation for every security function\",\"publisher\":{\"@id\":\"https:\/\/swimlane.com\/es\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/swimlane.com\/es\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/swimlane.com\/es\/#organization\",\"name\":\"Low-Code Security Automation & SOAR Platform | Swimlane\",\"url\":\"https:\/\/swimlane.com\/es\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/swimlane.com\/es\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/swimlane.com\/wp-content\/uploads\/sw-inline-logo-color-white.svg\",\"contentUrl\":\"https:\/\/swimlane.com\/wp-content\/uploads\/sw-inline-logo-color-white.svg\",\"width\":912,\"height\":190,\"caption\":\"Low-Code Security Automation & SOAR Platform | Swimlane\"},\"image\":{\"@id\":\"https:\/\/swimlane.com\/es\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/swimlane\",\"https:\/\/www.linkedin.com\/company\/swimlane\/\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"No preguntes qu\u00e9 pueden hacer por ti los sindicalistas; pregunta qu\u00e9 puedes hacer t\u00fa para sindicalizarte\u2026","description":"Los tipos de uni\u00f3n son \u00fatiles cuando se tiene una colecci\u00f3n de clases que no act\u00faan, pero que deben ser tratadas de la misma manera. Como desarrollador de software en\u2026","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:\/\/swimlane.com\/es\/blog\/tipos-de-union\/","og_locale":"es_ES","og_type":"article","og_title":"Ask Not What Union Types Can Do For You; Ask What You Can Do to Union Types","og_description":"Union types are useful when you have a collection of classes that do not act, but must all be acted upon in the same way. As a software developer at\u2026","og_url":"https:\/\/swimlane.com\/es\/blog\/tipos-de-union\/","og_site_name":"AI Security Automation","article_modified_time":"2026-02-05T04:50:46+00:00","og_image":[{"width":1120,"height":696,"url":"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@swimlane","twitter_misc":{"Tiempo de lectura":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/swimlane.com\/es\/blog\/union-types\/","url":"https:\/\/swimlane.com\/es\/blog\/union-types\/","name":"No preguntes qu\u00e9 pueden hacer por ti los sindicalistas; pregunta qu\u00e9 puedes hacer t\u00fa para sindicalizarte\u2026","isPartOf":{"@id":"https:\/\/swimlane.com\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swimlane.com\/es\/blog\/union-types\/#primaryimage"},"image":{"@id":"https:\/\/swimlane.com\/es\/blog\/union-types\/#primaryimage"},"thumbnailUrl":"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png","datePublished":"2021-02-25T16:00:00+00:00","dateModified":"2026-02-05T04:50:46+00:00","description":"Los tipos de uni\u00f3n son \u00fatiles cuando se tiene una colecci\u00f3n de clases que no act\u00faan, pero que deben ser tratadas de la misma manera. Como desarrollador de software en\u2026","breadcrumb":{"@id":"https:\/\/swimlane.com\/es\/blog\/union-types\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swimlane.com\/es\/blog\/union-types\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/swimlane.com\/es\/blog\/union-types\/#primaryimage","url":"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png","contentUrl":"https:\/\/swimlane.com\/wp-content\/uploads\/2021-02-UnionTypes.png","width":1120,"height":696,"caption":"Two figures pushing cube and cylinder shapes, symbolizing process comparison"},{"@type":"BreadcrumbList","@id":"https:\/\/swimlane.com\/es\/blog\/union-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swimlane.com\/"},{"@type":"ListItem","position":2,"name":"Ask Not What Union Types Can Do For You; Ask What You Can Do to Union Types"}]},{"@type":"WebSite","@id":"https:\/\/swimlane.com\/es\/#website","url":"https:\/\/swimlane.com\/es\/","name":"Automatizaci\u00f3n de seguridad de c\u00f3digo bajo y plataforma SOAR | Swimlane","description":"Automatizaci\u00f3n de la inteligencia artificial para todas las funciones de seguridad","publisher":{"@id":"https:\/\/swimlane.com\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swimlane.com\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/swimlane.com\/es\/#organization","name":"Automatizaci\u00f3n de seguridad de c\u00f3digo bajo y plataforma SOAR | Swimlane","url":"https:\/\/swimlane.com\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/swimlane.com\/es\/#\/schema\/logo\/image\/","url":"https:\/\/swimlane.com\/wp-content\/uploads\/sw-inline-logo-color-white.svg","contentUrl":"https:\/\/swimlane.com\/wp-content\/uploads\/sw-inline-logo-color-white.svg","width":912,"height":190,"caption":"Low-Code Security Automation & SOAR Platform | Swimlane"},"image":{"@id":"https:\/\/swimlane.com\/es\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/swimlane","https:\/\/www.linkedin.com\/company\/swimlane\/"]}]}},"publishpress_future_workflow_manual_trigger":{"enabledWorkflows":[]},"_links":{"self":[{"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/sw_resource\/9574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/sw_resource"}],"about":[{"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/types\/sw_resource"}],"author":[{"embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/users\/5"}],"version-history":[{"count":0,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/sw_resource\/9574\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/media\/9575"}],"wp:attachment":[{"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/media?parent=9574"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/tags?post=9574"},{"taxonomy":"resource-type","embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/resource-type?post=9574"},{"taxonomy":"resource-topic","embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/resource-topic?post=9574"},{"taxonomy":"resource-industry","embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/resource-industry?post=9574"},{"taxonomy":"blog-category","embeddable":true,"href":"https:\/\/swimlane.com\/es\/wp-json\/wp\/v2\/blog-category?post=9574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}