# Parttern Matching issue with text variables in motoko

**URL:** <https://forum.dfinity.org/t/parttern-matching-issue-with-text-variables-in-motoko/12990>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [May 15, 2022, 10:08am UTC](https://forum.dfinity.org/t/parttern-matching-issue-with-text-variables-in-motoko/12990 "2022-05-15T10:08:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomijaga](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tomijaga/32/4389_2.png) [@tomijaga](https://forum.dfinity.org/u/tomijaga)\
**Post date:** [May 15, 2022, 10:08am UTC](https://forum.dfinity.org/t/parttern-matching-issue-with-text-variables-in-motoko/12990/1 "2022-05-15T10:08:59Z")

</div>

> **[Motoko Playground - DFINITY](https://m7sm4-2iaaa-aaaab-qabra-cai.raw.ic0.app/?tag=4291415706)**
>
> A playground for the Internet Computer's native Motoko language, brought to you by DFINITY

> **[Motoko Playground - DFINITY](https://m7sm4-2iaaa-aaaab-qabra-cai.raw.ic0.app/?tag=4291415706)**
>
> A playground for the Internet Computer's native Motoko language, brought to you by DFINITY

I have this piece of code that returns an error

```bash
this pattern is never matched

```

There are two variables defined

```auto
let Get = "GET";
let Post = "POST";

```

I defined switch cases for both variables, but the first variable matches every text instead of the assigned text. This is an issue because it blocks the code from going to the other switch cases.

```nohighlight
switch (method){
    case (Get){
        ...
    };
    case (Post){ // this pattern is never matched
        ...
    };
}

```

However, It works when I create switch cases with raw text instead of with variables.

```auto
switch (method){
    case ("GET"){
        ...
    };
    case ("POST"){
        ...
    };
}

```

Is this a bug, or was this the intended design choice for Motoko?

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [May 15, 2022, 11:52am UTC](https://forum.dfinity.org/t/parttern-matching-issue-with-text-variables-in-motoko/12990/2 "2022-05-15T11:52:03Z")

</div>

I think it’s a bug in the sense that _your_ code contains something you probably didn’t intend, and the compiler error is informing you of that.

When you write `case (Get)` you aren’t comparing `method` with the previous binding of `Get` but instead are creating a new binding called `Get` which contains all of the possible values of `method`.

See: [Language quick reference | Internet Computer Developer Portal](https://smartcontracts.org/docs/current/developer-docs/build/languages/motoko/language-manual#identifier-pattern)

I’m not sure how to do what you intended if you don’t want to use the literal pattern. Your only option might be to use `if method == Get`.
