# Is String? any special?

**URL:** <https://forum.crystal-lang.org/t/is-string-any-special/1037>\
**Category:** Help & Support\
**Created:** [August 10, 2019, 8:41pm UTC](https://forum.crystal-lang.org/t/is-string-any-special/1037 "2019-08-10T20:41:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyku](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kyku/32/514_2.png) [@kyku](https://forum.crystal-lang.org/u/kyku)\
**Post date:** [August 10, 2019, 8:41pm UTC](https://forum.crystal-lang.org/t/is-string-any-special/1037/1 "2019-08-10T20:41:43Z")

</div>

I’m doing some type dispatching based on \*.class overloading. I handle all nullable types in a generic function, so that I don’t have to repeat myself. This seems to work fine both for built-in types and user-defined classes, but not with String?. Take a look at the following example:

```
def x(t : Int32.class); puts t; end
def x(t : String.class); puts t; end
def x(t : (T | Nil).class) forall T; puts t; end

x(Int32) # => Int32
x(Int32?) # => (Int32 | Nil)
x(String) # => String

# Uncommenting the following line yields compile time error:
#x(String?)

```

The error is:

> no overload matches ‘x’ with type (String | Nil).class  
> Overloads are:
> 
> - x(t : Int32.class)
> - x(t : String.class)
> - x(t : T | Nil.class)

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [August 10, 2019, 10:24pm UTC](https://forum.crystal-lang.org/t/is-string-any-special/1037/2 "2019-08-10T22:24:09Z")

</div>

It’s a bug. Happens if the class is named `String2` too. I think `T?.class` doesn’t work well in the sense that it doesn’t get inserted in the right order. Please report it as a bug. Thank you!

---

<div class="post-metadata">

**Author:** ![kyku](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kyku/32/514_2.png) [@kyku](https://forum.crystal-lang.org/u/kyku)\
**Post date:** [August 12, 2019, 1:49pm UTC](https://forum.crystal-lang.org/t/is-string-any-special/1037/3 "2019-08-12T13:49:18Z")

</div>

> <https://github.com/crystal-lang/crystal/issues/8071>
>
> I’m doing some type dispatching based on \*.class overloading. I handle all nullable types in a generic function, so that I...
