Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 400 401 [402] 403 404 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 908456 times)

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6015 on: June 27, 2014, 05:16:22 pm »

Spaceship operator comes up almost everytime I want to sort something in ruby.

obj_list.sort{|a,b|  b.hotness <=> a.hotness}

Or if I want to sort on multiple criteria, then I get to pair it with questionmark-colon:

obj_list.sort{|a,b|  (b.hotness != a.hotness ? b.hotness <=> a.hotness : b.snazziness <=> a.snazziness)}
« Last Edit: June 27, 2014, 05:19:49 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6016 on: June 27, 2014, 05:26:32 pm »

I'm particular to the binding operator ("=~"). Dunno if it exists anywhere but Perl, but what it does is apply a regular expression match or substitution to a string.
Logged

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6017 on: June 27, 2014, 05:28:27 pm »

So <=> is basically a comparator while my brain keeps thinking it should be equivalence. It's somewhere around the "Why doesn't this language support caret-exponentiation!?" level of pet peeve.
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6018 on: June 27, 2014, 08:24:47 pm »

Mine is the Goes To operator.

*runs away and hides*
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6019 on: June 27, 2014, 08:40:53 pm »

My favorite is COMEFROM

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6020 on: June 28, 2014, 12:08:11 am »

I'm going through the Android app dev tutorial on their site, and so far my feelings are summarized with this: "Android is weird."

All these "intents" and "fragments".. how do you even get a game working with this?

Make the game in Unity?
Logged

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6021 on: June 30, 2014, 09:20:51 am »

Second best operator is good old questionmark-colon.
The Ternary Operator.

Well, I mean, it's not literally the only ternary operator, but it's the only one you're likely to ever see, so it's still called "the" ternary operator. :)
« Last Edit: June 30, 2014, 09:24:39 am by GlyphGryph »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6022 on: June 30, 2014, 09:34:59 am »

Lua does that funny; instead of undescribedVariable =  someCondition ? ifTrue : ifFalse, it's undescribedVariable =  someCondition and ifTrue or ifFalse.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6023 on: June 30, 2014, 10:08:02 am »

That... would not result in the same behaviour.

if a= true
b= false
c= true

a ? b : c
=> false;
a and b or c
=> true

The Lua way equivalent is:
if a then b else c end

Or something thereabouts.

Personally, I would never use the method you described - it's a great way to shoot yourself in the foot and lead to laborious and difficult to figure out bugs later on.

I don't know the Lua rules for truthiness, those would determine how likely writing it that way is to screw you over. :) A glance at the internet shows that the only falsy values in Lua seem to be actual "false" values and "nil" values, so it would potentially be a rare problem... but that would make it all the more difficult to track down if it occurred.
« Last Edit: June 30, 2014, 10:16:06 am by GlyphGryph »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #6024 on: June 30, 2014, 12:04:33 pm »

Imma let you finish but Scala has the best ternary operator :)

It's just
Code: [Select]
val y = true
val x = if (y) 10 else 20

Of with multiple ifs
Code: [Select]
val y = 30
val x = if (y == 20) "hello"
    else if (y == 30) "world"
    else "piano!"

Or pattern matching
Code: [Select]
val y : Option[Boolean] = Some(true)
val x = y match {
    case Some(true) => "Hello"
    case Some(false) => "World"
    case None => "Trinary!"
}

Turns out making everything have some return value actually is pretty cool. I actually have started to miss it when working in other languages.

All these "intents" and "fragments".. how do you even get a game working with this?

I think most of those are  for UI applications, so for "give me OpenGL canvas and draw to it" aren't particularly useful.
« Last Edit: June 30, 2014, 12:09:03 pm by MorleyDev »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #6025 on: July 01, 2014, 11:20:44 am »

So double post, but...

Am I the only person on this entire planet who managed to stumble across how you can launch a build for any compiler through cmake without invoking the actual build tool directly?
cmake --build [cache location]

It even has build in support for targets
cmake --build [cache location] --target install

And for configuration (which is vital for multi-config makefiles, like the solutions generator for Visual Studio).
cmake --build [cache location] --config debug
cmake --build [cache location] --config debug --target install

It just seems like nobody ever uses these, never recommends them on stackoverflow, nothing. Either I'm missing an obvious flaw, or it seems like nobody actually knows about this incredibly useful feature! 0_o
« Last Edit: July 01, 2014, 11:35:05 am by MorleyDev »
Logged

Kirbypowered

  • Bay Watcher
  • Proficient Dabbler
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6026 on: July 01, 2014, 01:38:42 pm »

So I'd like to start some progress towards making my own roguelike in C++...Any suggestions on where to start? What I should know, learn about, where/how to learn it, and the like would be useful.

For reference, I'm currently able to put together simple little programs that function solely through the command prompt using preexisting libraries and the like. Most recently, I made a nifty little program to convert a number of any base into any other base (which ended up being simpler than I expected...), up to base 16. Really boosted my moral to be able to make it, but feel free to point and laugh at my lack of programming skills.
Logged
THE WINTER MEN COME DOWN THE VALLEY AND KILL KILL KILL.
I'm voting for the Plaid Acre up next on COLORS AND MEASUREMENTS weekly.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6027 on: July 01, 2014, 01:48:45 pm »

1) Ask yourself "How much of a roguelike can I do right now?". Do that.
2) Ask yourself "What does my roguelike need next? Do I know how to code that?" If yes, code that. If no, make your idea simpler until you can code that, then code that.
3) Ask yourself "Is there a part of my program that I am able to expand and add features to?" If yes, do that.
4) Ask yourself "Is there any part of my program that could have been written better?". If yes, fix that.
5) Go to step 2.
« Last Edit: July 01, 2014, 01:51:09 pm by MagmaMcFry »
Logged

Kirbypowered

  • Bay Watcher
  • Proficient Dabbler
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6028 on: July 01, 2014, 02:57:38 pm »

Spoiler: Progress (click to show/hide)

am i doing it right
Logged
THE WINTER MEN COME DOWN THE VALLEY AND KILL KILL KILL.
I'm voting for the Plaid Acre up next on COLORS AND MEASUREMENTS weekly.

Twiggie

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6029 on: July 01, 2014, 03:07:50 pm »

yup. what you gonna add next?
Logged
Pages: 1 ... 400 401 [402] 403 404 ... 796